2016-05-10 40 views
5

Glide ile okhttp3 kullanıyorum, bu yüzden entegrasyon bölümünü de ekledim.Okhttp3 tümleştirmesi ile Glide java.lang.NoClassDefFoundError

compile 'com.squareup.okhttp3:okhttp:3.2.0' 
compile 'com.github.bumptech.glide:glide:3.6.1' 
compile 'com.github.bumptech.glide:okhttp-integration:[email protected]' 

Hatta

compile 'com.android.support:multidex:1.0.1' 

kullanarak ve uygulama sınıfının İşte

@Override 
    protected void attachBaseContext(Context base) { 
     super.attachBaseContext(base); 
     MultiDex.install(base); 
    } 

bu ekleme multidex destek etkin tam yığın izlemesi var - bu yapılandırma

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/okhttp/OkHttpClient; 
at com.bumptech.glide.integration.okhttp.OkHttpUrlLoader$Factory.getInternalClient(OkHttpUrlLoader.java:30) 
at com.bumptech.glide.integration.okhttp.OkHttpUrlLoader$Factory.<init>(OkHttpUrlLoader.java:41) 
at com.bumptech.glide.integration.okhttp.OkHttpGlideModule.registerComponents(OkHttpGlideModule.java:31) 
at com.bumptech.glide.Glide.get(Glide.java:157) 
at com.bumptech.glide.RequestManager.<init>(RequestManager.java:62) 
at com.bumptech.glide.RequestManager.<init>(RequestManager.java:53) 
at com.bumptech.glide.manager.RequestManagerRetriever.supportFragmentGet(RequestManagerRetriever.java:198) 
at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:104) 
at com.bumptech.glide.Glide.with(Glide.java:644) 
at com.skcsllp.mutterfly.activities.EditProfileActivity.onCreate(EditProfileActivity.java:76) 
at android.app.Activity.performCreate(Activity.java:6100) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601) 
at android.app.ActivityThread.access$800(ActivityThread.java:178) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:194) 
at android.app.ActivityThread.main(ActivityThread.java:5637) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 


    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.okhttp.OkHttpClient" on path: DexPathList[[dex file 
"/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-support-annotations-23.2.1_711eea7d990a3279fc66c06b239bf29196aabc02-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_9-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_8-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_7-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_6-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_5-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_4-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_3-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_2-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_1-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-slice_0-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-okio-1.6.0_4cb2265fa47e13dbef896857be4ee851d4d21b93-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-okhttp-3.2.0_c46370073bf914e884c23455554d5f56e9b15f17-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-internal_impl-23.2.1_945649fcb49395f2024bfee914abcd2b33619e3f-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-gson-2.2.4_d0ce76b63ce905fbab3c5d385c8e1b8692010f19-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-glide-3.6.1_362f6061e938ba7d3e28c67a4832a9a19bdf24aa-classes.dex", 
dex file "/data/data/com.skcsllp.mutterfly.debug/files/instant-run/dex/slice-com.google.android.gms-play-services-gcm-7.8.0_defd878a1ea68768e6e678ca0946f67a973b8929-classes.dex", 

olduğunu inşa etmek

productFlavors { 
     // Define separate dev and prod product flavors. 
     dev { 
      // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin 
      // to pre-dex each module and produce an APK that can be tested on 
      // Android Lollipop without time consuming dex merging processes. 
      minSdkVersion 21 
     } 
     prod { 
      // The actual minSdkVersion for the application. 
      minSdkVersion 15 
     } 
    } 

Dex işleminde neyin yanlış olduğunu anlayamadım. Eğer çok fazla yöntem yoksa ben sadece build.gradle

compile 'com.github.bumptech.glide:okhttp-integration:[email protected]' 
+0

@TWiStErRob herhangi bir yardım? –

+0

Çapraz bağlantı: https://github.com/bumptech/glide/issues/1190 – TWiStErRob

cevap

7

gelen multidex için ihtiyaç entegrasyon bölümünü kaldırırsanız

DÜZENLEME

Her şey iyi çalışıyor.

sen (v2) veya okhttp3 okhttp kullanıyorsanız karar verin ve buna göre kodunuzu güncelleyin:

compile 'com.github.bumptech.glide:okhttp-integration:[email protected]' 
compile 'com.squareup.okhttp:okhttp:2.7.5' 

veya

compile 'com.github.bumptech.glide:okhttp3-integration:[email protected]' 
compile 'com.squareup.okhttp3:okhttp:3.2.0' 

Oku https://github.com/bumptech/glide/wiki/Integration-Libraries fazla ayrıntı için.

(Kaynak: https://github.com/bumptech/glide/issues/1158#issuecomment-215007390)

+0

Teşekkürler! işe yaradı! –

+1

Yaptığım özel modülde okhttp3'i entegre ettim ve çalışmıyor, lütfen bana yardımcı olabilir misiniz? Retrofit 2.0.2 kullanıyorum – MrIndomitable

+1

@SamuelCardo evet, yardımcı olabilirim. – TWiStErRob