Reputation: 109
When we upgrade react native from 0.57.8 to 0.58.6, we experiences the issue on android
we couldn't find the root cause why it couldn't find the implementation.
Thanks.
The log from android studio is as below:
V/StudioProfiler: Transformed class: okhttp3/OkHttpClient W/xxxxx: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it! D/NetworkSecurityConfig: No Network Security Config specified, using platform default W/gov.nsw.servic: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setUseSessionTickets(Z)V (light greylist, reflection) W/gov.nsw.servic: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setHostname(Ljava/lang/String;)V (light greylist, reflection) Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (light greylist, reflection) Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setAlpnProtocols([B)V (light greylist, reflection) Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, reflection) Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, reflection) Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (light greylist, reflection) D/ReactNative: ReactInstanceManager.createReactContextInBackground() ReactInstanceManager.recreateReactContextInBackgroundInner() E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2 Process: xxxx, PID: 8127 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:354) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.AbstractMethodError: abstract method "okio.Timeout okhttp3.Call.timeout()" at okhttp3.internal.ws.RealWebSocket.connect(RealWebSocket.java:190) at okhttp3.OkHttpClient.newWebSocket(OkHttpClient.java:442) at com.facebook.react.devsupport.InspectorPackagerConnection$Connection.connect(InspectorPackagerConnection.java:251) at com.facebook.react.devsupport.InspectorPackagerConnection.connect(InspectorPackagerConnection.java:52) at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:230) at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:222) at android.os.AsyncTask$2.call(AsyncTask.java:333) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: xxxxx, PID: 8127 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:354) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.AbstractMethodError: abstract method "okio.Timeout okhttp3.Call.timeout()" at okhttp3.internal.ws.RealWebSocket.connect(RealWebSocket.java:190) at okhttp3.OkHttpClient.newWebSocket(OkHttpClient.java:442) at com.facebook.react.packagerconnection.ReconnectingWebSocket.connect(ReconnectingWebSocket.java:77) at com.facebook.react.packagerconnection.JSPackagerClient.init(JSPackagerClient.java:89) at com.facebook.react.devsupport.DevServerHelper$1.doInBackground(DevServerHelper.java:197) at com.facebook.react.devsupport.DevServerHelper$1.doInBackground(DevServerHelper.java:151) at android.os.AsyncTask$2.call(AsyncTask.java:333) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) I/Process: Sending signal. PID: 8127 SIG: 9 W/.0.2.2:8081/...: type=1400 audit(0.0:777): avc: denied { write } for 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 permissive=0 type=1400 audit(0.0:778): avc: denied { write } for 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 permissive=0 Disconnected from the target VM, address: 'localhost:8673', transport: 'socket'
Upvotes: 1
Views: 1195
Reputation: 2621
After some research on investigating this issue here is what I found out:
Apparently, this crash is caused due to a timeout error when the React Native package uses okhttp3 by the time a React Native application instance is created.
Digging deeper into this log, I found that the RealWebSocket.java:192 file in okhttp3 repo, introduced a change that clears the time out, this change mess with some classes inside the React lib packager Connection package and therefore produces the crash.
Notice that this change was introduced in okhttp version 3.12.0 commit 04a74b2. This means that any version below this one is completely compatible with React lib.
Furthermore, I also found that this change was reverted in the most recent okhttp version 3.14.0 commit e6cfc2a bringing back the stable interaction with React lib and okhttp
I would recommend you do not use okhttp 3.12.0 and instead follow the next criteria for your okhttp implementation:
3.11.0>= okhttp >=3.14.0
After that, your app should be working like a charm.
PS. If you have other dependencies in your Gradle file that required the usage of okhttp 1.12.0 (Like in my case) exclude this lib from them.
Upvotes: 3