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!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM