集成okhttp的时候 在4.4以上版本都没问题,突然在4.4.2版本的手机上报了如下错误:
E/CrashReport: # CRASH STACK:
E/CrashReport: java.lang.NoClassDefFoundError: okhttp3.OkHttpClient
at pack.http.HttpMethod.<init>(HttpMethod.java:75)
at pack.http.HttpMethod.<init>(HttpMethod.java:54)
at pack.http.HttpMethod$sinalInstance.<clinit>(HttpMethod.java:98)
at pack.http.HttpMethod.getInstance(HttpMethod.java:102)
at pack.ui.login.LoginActivity.getSys(LoginActivity.java:136)
at pack.ui.login.LoginActivity.setUp(LoginActivity.java:105)
at pack.ui.login.LoginActivity.onCreate(LoginActivity.java:92)
at android.app.Activity.performCreate(Activity.java:5285)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2345)
at android.app.ActivityThread.access$1100(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5314)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
at dalvik.system.NativeStart.main(Native Method)
E/CrashReport: #++++++++++++++++++++++++++++++++++++++++++#
build.gradle关键配置如下
defaultConfig{
multiDexEnabled true
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
}
Application关键配置如下
public class MvpApplication extends Application{
@Override
public void onCreate() {
MultiDex.install(this);
}
}