Jetzt möchte ich Espresso verwenden, um meine app ui zu testen, aber wenn ich Fresko-Bibliothek verwenden, wie ein SimpleDreweeView in xml, wird der Espresso mit Fehlern nicht bestanden:Android ui Test mit Espresso kann nicht verwendet werden Fresko SimpleDreweeView
android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.facebook.drawee.view.SimpleDraweeView
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:474)
at android.app.Activity.setContentView(Activity.java:2388)
at com.example.android.testing.espresso.intents.AdvancedSample.ImageViewerActivity.onCreate(ImageViewerActivity.java:45)
So kann mir jeder helfen, das Problem zu lösen ?? Danke vielmals!!
Meine XML-Datei:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin"
tools:context=".ImageViewerActivity">
<Button android:id="@+id/button_take_photo"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_open_camera"
android:layout_gravity="center_horizontal"
android:onClick="onOpenCamera"
android:layout_marginTop="32dp"/>
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="128dp"
android:layout_height="128dp"
android:id="@+id/imageView"
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"
android:background="#ffdbdbdb"/>
</LinearLayout>
ImageViewActivity:
public class ImageViewerActivity extends Activity {
@VisibleForTesting
protected static final String KEY_IMAGE_DATA = "data";
private static final int REQUEST_IMAGE_CAPTURE = 1;
private SimpleDraweeView mImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_viewer);
mImageView = (SimpleDraweeView) findViewById(R.id.imageView);
}
private void dispatchTakePictureIntent() {
// Open the camera to take a photo.
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
public void onOpenCamera(View view) {
dispatchTakePictureIntent();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// If an image is received, display it on the ImageView.
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
if (extras == null || !extras.containsKey(KEY_IMAGE_DATA)) {
return;
}
Bitmap imageBitmap = (Bitmap) extras.get(KEY_IMAGE_DATA);
mImageView.setImageBitmap(imageBitmap);
}
}
}
ich die Google offizielle Demo nur ändern, ersetzen Sie die Bildansicht simpledraweeview und fehleranfällig ....
Bitte fügen Sie Ihre ** xml ** Datei und ** ImageViewerActivity ** ein. –
Update, bitte überprüfen, danke –