Android 5.X以下的操作系统,就会出现这个问题,5.X以上一切运行正常!
求高手解答
求高手解答
05-08 19:14:15.386 28103-28103/com.pd.user E/AndroidRuntime: FATAL EXCEPTION: main Process: com.pd.user, PID: 28103 java.lang.NoClassDefFoundError: okhttp3.OkHttpClient at com.pd.user.net.OkHttpClientManager.<init>(OkHttpClientManager.java:50) at com.pd.user.net.OkHttpClientManager.<init>(OkHttpClientManager.java:40) at com.pd.user.net.OkHttpClientManager$SingLetonHolder.<clinit>(OkHttpClientManager.java:72) at com.pd.user.net.OkHttpClientManager.getInstance(OkHttpClientManager.java:77) at com.pd.user.activity.MainActivity.initData(MainActivity.java:196) at com.pd.user.activity.MainActivity.onCreate(MainActivity.java:75) at android.app.Activity.performCreate(Activity.java:5312) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5883) 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:871) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) at dalvik.system.NativeStart.main(Native Method)
解决方案
5
Android系统从哪个版本开始,不记得了,不是4点几就是5.0,内部网络开始使用okhttp,而之前使用的是httpurlconnection和httpclient,所以以前的版本不能直接使用okhttp,要导入jar包
5
包冲突了,存在两个okhttp包,不知道应该调用哪一个包的方法就会出现这个问题
10
对啊,你下面的已经compile “com.squareup.okhttp3:okhttp:3.2.0″,然后上面的app又导入下面这个,然后又导入了okhttp3.2的jar包,不就冲突了吗?