2016-05-12 70 views
0

我想創建應用程序使用Fresco庫縮放功能使用ZoomableDraweeView但當我開始我的應用程序,應用程序崩潰。以下是我的代碼,請幫助我解決此問題並提前致謝。Android壁畫:錯誤膨脹類com.facebook.samples.zoomable.ZoomableDraweeView

public class ZoomActivity extends Activity { 

    private ZoomableDraweeView view; 
    private DraweeController ctrl; 
    private GenericDraweeHierarchy hierarchy; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     Fresco.initialize(this); 
     setContentView(R.layout.activity_zoom); 

     Uri imageUri = Uri.parse("http://i.imgur.com/76Jfv9b.jpg"); 
     view = (ZoomableDraweeView) findViewById(R.id.zoomable); 

     ctrl = Fresco.newDraweeControllerBuilder().setUri(imageUri).setTapToRetryEnabled(true).build(); 
     hierarchy = new GenericDraweeHierarchyBuilder(getResources()) 
       .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER) 
       .setProgressBarImage(new ProgressBarDrawable()) 
       .build(); 
     view.setController(ctrl); 
     view.setHierarchy(hierarchy); 
    } 
} 

這是我的佈局。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    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" 
    tools:context="com.example.android.imageloaderexample.Activity.Fresco.ZoomActivity"> 

    <com.facebook.samples.zoomable.ZoomableDraweeView 
     android:id="@+id/zoomable" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
</RelativeLayout> 

這是Gradle。

apply plugin: 'com.android.application' 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.example.android.imageloaderexample" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 
dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile files('libs/picasso-2.5.2.jar') 
    compile files('libs/universal-image-loader-1.9.5.jar') 
    compile files('libs/glide-3.6.1.jar') 
    compile 'com.facebook.fresco:fresco:0.10.0' 
    compile 'com.facebook.fresco:animated-gif:0.10.0' 
    compile "com.facebook.fresco:imagepipeline-okhttp:0.10.0+" 
} 

下面是我的logcate。

FATAL EXCEPTION: Process: com.example.android.imageloaderexample, PID: 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.imageloaderexample/com.example.android.imageloaderexample.Activity.Fresco.ZoomActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class com.facebook.samples.zoomable.ZoomableDraweeView 

at java.lang.ClassLoader.loadClass(ClassLoader.java:504)... 23 more 
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack availableBB 
+0

你能提供一個堆棧跟蹤嗎? –

回答

1
<com.example.android.imageloaderexample.Activity.ZoomableDraweeView 
    android:id="@+id/zoomable" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

請添加以下代碼它爲我工作和享受..。 !

相關問題