关于okhttp(java.lang.NoSuchMethodError: No interface method rangeEquals(JLokio/ByteString;)Z)错误

错误信息:

E/AndroidRuntime: FATAL EXCEPTION: Thread-2322
                                                                       Process: cn.vove7.sendjsondemo, PID: 18952
                                                                       Theme: themes:{com.cyanogenmod.trebuchet=overlay:system, com.tencent.mobileqq=overlay:org.cyanogenmod.hexolibre, com.android.settings=overlay:system}
                                                                       java.lang.NoSuchMethodError: No interface method rangeEquals(JLokio/ByteString;)Z in class Lokio/BufferedSource; or its super classes (declaration of 'okio.BufferedSource' appears in /data/app/cn.vove7.sendjsondemo-1/split_lib_dependencies_apk.apk:classes15.dex)
                                                                           at okhttp3.internal.Util.bomAwareCharset(Util.java:412)
                                                                           at okhttp3.ResponseBody.string(ResponseBody.java:173)
                                                                           at cn.vove7.sendjsondemo.MainActivity.post(MainActivity.java:84)
                                                                           at cn.vove7.sendjsondemo.MainActivity.access$000(MainActivity.java:18)
                                                                           at cn.vove7.sendjsondemo.MainActivity$1$1.run(MainActivity.java:49)
                                                                           at java.lang.Thread.run(Thread.java:818)

由于使用的引用外部jar包,就一直出错,


    compile files('src/main/res/lib/okhttp-3.6.0.jar')
    compile files('src/main/res/lib/okio-1.6.0.jar')

换为maven依赖即可


    compile 'com.squareup.okhttp3:okhttp:3.6.0'

猜你喜欢

转载自blog.csdn.net/qq_37299249/article/details/73149512