Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react native activity crashes, probably related to packaging okhttp3

have been struggling with this for a week, with no success.

I have started from a good boiler plate app (just another app), and added a click with detail activity being a React native activity.

As soon as I make the click the whole app crashes.

03-25 14:58:35.731 2746-4224/com.justanotherandroidapp.develop E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2 Process: com.justanotherandroidapp.develop, PID: 2746 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:325) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: java.lang.NoSuchMethodError: No virtual method setCallWebSocket(Lokhttp3/Call;)V in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/com.justanotherandroidapp.develop-2/split_lib_dependencies_apk.apk:classes57.dex) at okhttp3.ws.WebSocketCall.enqueue(WebSocketCall.java:108) at com.facebook.react.devsupport.InspectorPackagerConnection$Connection.connect(InspectorPackagerConnection.java:243) at com.facebook.react.devsupport.InspectorPackagerConnection.connect(InspectorPackagerConnection.java:44) at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:168) at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:164) at android.os.AsyncTask$2.call(AsyncTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  at java.lang.Thread.run(Thread.java:761) 

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

The whole app is on GitHub https://github.com/vladp/Just-Another-Android-App

It crashes in ReactNative's DevSuportManagerImpl.java (using react native 0.42, API 25) between these 2 calls

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

(line 878, 879 in node_modules\react-native\android\com\facebook\react\react-native\0.42.3\react-native-0.42.3-sources.jar!\com\facebook\react\devsupport\DevSupportManagerImpl.java )

The issue does not improve whether I delete or add okhttp and okhttp-ws from my 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'

Appreciate in advance any help.

like image 717
V P Avatar asked Feb 05 '23 19:02

V P


1 Answers

finally figured out what to do. I forced gradle to resolve all references to okhttp to version 3.4.1. Thankfully in my test app, all the other components tolerated being 'forced to lowest common denominator' (that being the 3.4.1 version of okhttp used by react native).

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

The above line turned out to be solution for which I spent probably 30 hours on...

like image 99
V P Avatar answered Feb 10 '23 22:02

V P