java.lang.AbstractMethodError:抽象方法“ okio.Timeout okhttp3.Call.timeout()”

时间:2019-03-14 21:49:57

标签: react-native-android okhttp3

当我们将本机反应从0.57.8升级到0.58.6时,我们会在android上遇到问题

我们找不到根本无法实现的根本原因。

谢谢。

android studio的日志如下:

V / StudioProfiler:转换后的类:okhttp3 / OkHttpClient W / xxxxx:当前dex文件中包含多个类。如果未对其进行任何转换,则在此类上调用RetransformClasses可能会失败! D / NetworkSecurityConfig:未指定网络安全配置,使用平台默认值 W / gov.nsw.servic:访问隐藏的方法Lcom / android / org / conscrypt / OpenSSLSocketImpl;-> setUseSessionTickets(Z)V(浅灰色列表,反射) W / gov.nsw.servic:访问隐藏的方法Lcom / android / org / conscrypt / OpenSSLSocketImpl;-> setHostname(Ljava / lang / String;)V(浅灰色列表,反射)                   访问隐藏的方法Lcom / android / org / conscrypt / OpenSSLSocketImpl;-> getAlpnSelectedProtocol()[B(浅灰色列表,反射)                   访问隐藏的方法Lcom / android / org / conscrypt / OpenSSLSocketImpl;-> setAlpnProtocols([B)V(浅灰色列表,反射)                   访问隐藏的方法Ldalvik / system / CloseGuard;-> get()Ldalvik / system / CloseGuard; (浅灰色清单,反射)                   访问隐藏的方法Ldalvik / system / CloseGuard;-> open(Ljava / lang / String;)V(浅灰色列表,反射)                   访问隐藏的方法Ldalvik / system / CloseGuard;-> warnIfOpen()V(浅灰色列表,反射) D / ReactNative:ReactInstanceManager.createReactContextInBackground()                ReactInstanceManager.recreateReactContextInBackgroundInner() E / AndroidRuntime:致命例外:AsyncTask#2                   程序:xxxx,PID:8127                   java.lang.RuntimeException:执行doInBackground()时发生错误                       在android.os.AsyncTask $ 3.done(AsyncTask.java:354)                       在java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)                       在java.util.concurrent.FutureTask.setException(FutureTask.java:252)                       在java.util.concurrent.FutureTask.run(FutureTask.java:271)                       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)                       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641)                       在java.lang.Thread.run(Thread.java:764)                     原因:java.lang.AbstractMethodError:抽象方法“ okio.Timeout okhttp3.Call.timeout()”                       在okhttp3.internal.ws.RealWebSocket.connect(RealWebSocket.java:190)                       在okhttp3.OkHttpClient.newWebSocket(OkHttpClient.java:442)                       在com.facebook.react.devsupport.InspectorPackagerConnection $ Connection.connect(InspectorPackagerConnection.java:251)                       在com.facebook.react.devsupport.InspectorPackagerConnection.connect(InspectorPackagerConnection.java:52)                       在com.facebook.react.devsupport.DevServerHelper $ 3.doInBackground(DevServerHelper.java:230)                       在com.facebook.react.devsupport.DevServerHelper $ 3.doInBackground(DevServerHelper.java:222)                       在android.os.AsyncTask $ 2.call(AsyncTask.java:333)                       在java.util.concurrent.FutureTask.run(FutureTask.java:266)                       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)                       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641)                       在java.lang.Thread.run(Thread.java:764) E / AndroidRuntime:致命异常:AsyncTask#1                   流程:xxxxx,PID:8127                   java.lang.RuntimeException:执行doInBackground()时发生错误                       在android.os.AsyncTask $ 3.done(AsyncTask.java:354)                       在java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)                       在java.util.concurrent.FutureTask.setException(FutureTask.java:252)                       在java.util.concurrent.FutureTask.run(FutureTask.java:271)                       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)                       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641)                       在java.lang.Thread.run(Thread.java:764)                    引起原因:java.lang.AbstractMethodError:抽象方法“ okio.Timeout okhttp3.Call.timeout()”                       在okhttp3.internal.ws.RealWebSocket.connect(RealWebSocket.java:190)                       在okhttp3.OkHttpClient.newWebSocket(OkHttpClient.java:442)                       在com.facebook.react.packagerconnection.ReconnectingWebSocket.connect(ReconnectingWebSocket.java:77)                       在com.facebook.react.packagerconnection.JSPackagerClient.init(JSPackagerClient.java:89)                       在com.facebook.react.devsupport.DevServerHelper $ 1.doInBackground(DevServerHelper.java:197)                       在com.facebook.react.devsupport.DevServerHelper $ 1.doInBackground(DevServerHelper.java:151)                       在android.os.AsyncTask $ 2.call(AsyncTask.java:333)                       在java.util.concurrent.FutureTask.run(FutureTask.java:266)                       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)                       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641)                       在java.lang.Thread.run(Thread.java:764) I / Process:正在发送信号。 PID:8127 SIG:9 W / .0.2.2:8081 / ...:类型= 1400审核(0.0:777):AVC:拒绝{写入} name =“ perfd” dev =“ dm-0” ino = 65541 scontext = u:r :untrusted_app_27:s0:c512,c768 tcontext = u:object_r:shell_data_file:s0 tclass = dir允许= 0                    类型= 1400审核(0.0:778):AVC:拒绝{写入}名称=“ perfd” dev =“ dm-0” ino = 65541 scontext = u:r:untrusted_app_27:s0:c512,c768 tcontext = u:object_r :shell_data_file:s0 tclass = dir允许= 0 与目标VM断开连接,地址:“ localhost:8673”,传输:“ socket”

1 个答案:

答案 0 :(得分:2)

经过一些调查此问题的研究后,我发现:

显然,此崩溃是由于在创建React Native应用程序实例时React Native软件包使用okhttp3而导致的超时错误引起的。

更深入地研究此日志,我发现okhttp3存储库中的RealWebSocket.java:192文件引入了清除超时的更改,此更改使React lib打包程序Connection包中的某些类混乱,因此导致崩溃

请注意,此更改是在okhttp版本3.12.0提交04a74b2中引入的。这意味着该版本以下的任何版本都与React lib完全兼容。

okhttp 3.12.0 release

此外,我还发现此更改在最新的okhttp版本3.14.0 commit e6cfc2a中得到了恢复,从而恢复了与React lib和okhttp的稳定交互。

okhttp 3.12.0 release

我建议您不要使用okhttp 3.12.0,而应遵循okhttp实现的下一个条件:

3.11.0> = okhttp> = 3.14.0

之后,您的应用应该像超级按钮一样工作。

PS。如果您在Gradle文件中还有其他依赖项需要使用okhttp 1.12.0(就我而言),则将它们排除在外。