反应原生活动崩溃,可能与打包okhttp3

时间:2017-03-25 19:21:04

标签: react-native okhttp3

一直在努力奋斗一周,但没有成功。

我从一个好的锅炉板应用程序(只是另一个应用程序)开始,并添加了一个点击,其中详细活动是React原生活动。

我点击后整个应用程序崩溃。

  

03-25 14:58:35.731 2746-4224 / com.justanotherandroidapp.develop   E / AndroidRuntime:FATAL EXCEPTION:AsyncTask#2                                                                                    过程:com.justanotherandroidapp.develop,PID:2746                                                                                    java.lang.RuntimeException:执行时发生错误   doInBackground()                                                                                        在android.os.AsyncTask $ 3.done(AsyncTask.java:325)                                                                                        在   java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)                                                                                        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)                                                                                        在java.util.concurrent.FutureTask.run(FutureTask.java:242)                                                                                        在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)                                                                                        在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:607)                                                                                        在java.lang.Thread.run(Thread.java:761)                                                                                     引起:java.lang.NoSuchMethodError:没有虚方法   setCallWebSocket(Lokhttp3 / Call;)V类Lokhttp3 / internal / Internal;   或其超级类('okhttp3.internal.Internal'的声明   出现在   /data/app/com.justanotherandroidapp.develop-2/split_lib_dependencies_apk.apk:classes57.dex)                                                                                        在okhttp3.ws.WebSocketCall.enqueue(WebSocketCall.java:108)                                                                                        在   com.facebook.react.devsupport.InspectorPackagerConnection $ Connection.connect(InspectorPackagerConnection.java:243)                                                                                        在   com.facebook.react.devsupport.InspectorPackagerConnection.connect(InspectorPackagerConnection.java:44)                                                                                        在   com.facebook.react.devsupport.DevServerHelper $ 3.doInBackground(DevServerHelper.java:168)                                                                                        在   com.facebook.react.devsupport.DevServerHelper $ 3.doInBackground(DevServerHelper.java:164)                                                                                        在android.os.AsyncTask $ 2.call(AsyncTask.java:305)                                                                                        在java.util.concurrent.FutureTask.run(FutureTask.java:237)                                                                                        在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)                                                                                        在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:607)                                                                                        在java.lang.Thread.run(Thread.java:761)

                                                                             --------- beginning of system

整个应用程序都在GitHub上 https://github.com/vladp/Just-Another-Android-App

它在ReactNative的DevSuportManagerImpl.java中崩溃(使用react native 0.42,API 25) 在这两个电话之间

  mDevServerHelper.openPackagerConnection(this);
  mDevServerHelper.openInspectorConnection();

(在node_modules \ react-native \ android \ com \ facebook \ react \ react-native \ 0.42.3 \ react-native-0.42.3-sources.jar!\ com \ facebook \ react \中的行878,879行devsupport \ DevSupportManagerImpl.java)

该问题无法改善我是删除还是添加okhttp和okhttp-ws 来自我的build.gradle

//React Native  -- start
compile ("com.facebook.react:react-native:0.42.+"){
            // https://github.com/facebook/react-native/issues/10233
            exclude group:'com.facebook.stetho', module:'stetho'
            exclude module: 'jsr305'

}

compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okhttp3:okhttp-ws:3.4.2'

提前感谢任何帮助。

1 个答案:

答案 0 :(得分:8)

终于弄明白该怎么做了。 我强制gradle将对okhttp的所有引用解析为版本3.4.1。 值得庆幸的是,在我的测试应用程序中,所有其他组件都被容忍为“被迫使用最低公分母”(即本机反应中使用的okhttp的3.4.1版本)。

configurations.all {
    resolutionStrategy {
        // force certain versions of dependencies (including transitive)
        force 'com.squareup.okhttp3:okhttp:3.4.1'
    }
}

以上这条线被证明是我花了大约30个小时的解决方案...