Fresco使用及问题

1. Android Studio使用远程依赖时下载不了jar包的解决方法

// 需要添加以下maven库,否则使用远程依赖时,可能无法下载fresco数据:compile ('com.facebook.fresco:fresco:0.4.0+')
// Error:(126, 14) Failed to resolve: com.facebook.fresco:fresco:0.4.0+
allprojects {
repositories {
mavenCentral()
}
}

 

2. Execution failed for task ':imagepipeline:ndk_build_gifimage'.

  如果你遇到这个错误,多半是找不到ndk环境导致的。配置了NDK环境变量就可以解决了。

 

3. 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'
}

 

4. 自定义网络加载:OkHttp

Image pipeline 默认使用HttpURLConnection。应用可以根据自己需求使用不同的网络库。

OkHttp

OkHttp 是一个流行的开源网络请求库。Image pipeline有一个使用OkHttp替换掉了Android默认的网络请求的补充。

如果需要使用OkHttp, 不要使用这个下载页面的gradle依赖配置,应该使用下面的依赖配置

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:

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);

 

5. java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[...] couldn't find "libmemchunk.so"

  64位机器暂时还有问题:Fresco does not put any libraries in "lib/arm64", it will be fixed by #176 soon.(已解决)

  Working on version 0.5.1!

 

posted on 2015-05-14 17:50  veins  阅读(7637)  评论(0编辑  收藏  举报

导航