Java.lang.noclassdeffounderror: Okhttp3.okhttpclient$builder
In my project, I have used OkHttp(version 2.5.0) as my network request library. But few days ago, I tried Retrofit2 as part of my app's network request library, as you know, the ne
Solution 1:
Yes, finally I find the problem and solve it. I viewed a similar problem here and find that maybe the 64K Methods could cause the problem, so I came to official site to view Building Apps with Over 64K Methods. Now you should compile the multidex library in your build.gradle file:
compile 'com.android.support:multidex:1.0.1'
And don't forget to config your defaultConfig:
android {
defaultConfig {
multiDexEnabled true
}
}
And finally you can write a BaseApplication extends to Application, over write the attachBaseContext(Context base) method as follows:
@OverrideprotectedvoidattachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Don't forget to add this to your AndroidManifest.xml file:
<applicationandroid:name=".BaseApplication"android:allowBackup="true"></application>
Post a Comment for "Java.lang.noclassdeffounderror: Okhttp3.okhttpclient$builder"