Fresco使用及問題java
allprojects { repositories { mavenCentral() } }
Execution failed for task ':imagepipeline:ndk_build_gifimage'.若是你遇到這個錯誤,多半是找不到ndk環境致使的。配置了NDK環境變量就能夠解決了。android
Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat // 因爲com.facebook.fresco:imagepipeline模塊引用了support-v4.jar, // 若是項目中的其餘模塊也引用了support-v4.jar, 那麼須要去掉其中一個模塊對support-v4.jar的引用(exclude module: 'support-v4') // 不然將會出現沒法正確引用目標support_v4.jar的狀況,或者報如下異常: // com.android.dex.DexException: // Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;網絡
compile ('com.facebook.fresco:fresco:0.4.0+') { exclude module: 'support-v4' }
dependencies { // your project's other dependencies compile 'com.facebook.fresco:drawee:0.4.0+' compile 'com.facebook.fresco:imagepipeline-okhttp:0.4.0+' }
配置Image pipeline這時也有一些不一樣,再也不使用ImagePipelineConfig.newBuilder,而是使用OkHttpImagePipelineConfigFactory:maven
Context context; OkHttpClient okHttpClient; // build on your own ImagePipelineConfig config = OkHttpImagePipelineConfigFactory .newBuilder(context, okHttpClient) . // other setters . // setNetworkFetchProducer is already called for you .build(); Fresco.initialize(context, config);
Working on version 0.5.1!gradle