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