我正在使用 okhttp3 和 glide,因此我已经添加了集成部分。
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.github.bumptech.glide:okhttp-integration:1.4.0@aar'
我甚至启用了多dex支持,使用:
compile 'com.android.support:multidex:1.0.1'
并将其添加到应用程序类中
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
以下是完整的堆栈跟踪:
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",
这是构建的配置文件。
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进程出了什么问题。
编辑
如果我从build.gradle中简单地删除集成部分,一切都运行得很好。
compile 'com.github.bumptech.glide:okhttp-integration:1.4.0@aar'