Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No static method delimiterOffset in class Lokhttp3/internal/Util #31382

Closed
HishamMubarak opened this issue Apr 19, 2021 · 5 comments
Closed

No static method delimiterOffset in class Lokhttp3/internal/Util #31382

HishamMubarak opened this issue Apr 19, 2021 · 5 comments
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.

Comments

@HishamMubarak
Copy link

Android app crashes in some devices and only in production.
Below is the error logs I collected from Sentry Logs and Play Store Crash reports.

Description

Sentry Log:
No static method delimiterOffset(Ljava/lang/String;IILjava/lang/String;)I in class Lokhttp3/internal/Util; or its super classes (declaration of 'okhttp3.internal.Util' appears in base.apk!classes3.dex)

Play Store Crash Logs

java.lang.NoSuchMethodError: 
  at okhttp3.JavaNetCookieJar.decodeHeaderAsJavaNetCookies (JavaNetCookieJar.java:91)
  at okhttp3.JavaNetCookieJar.loadForRequest (JavaNetCookieJar.java:74)
  at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest (ReactCookieJarContainer.java:44)
  at okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.kt:74)
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.kt:109)
  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.kt:76)
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.kt:109)
  at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp (RealCall.kt:201)
  at okhttp3.internal.connection.RealCall$AsyncCall.run (RealCall.kt:517)
  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:919)https://reactnative.dev/docs/upgrading.html

React Native version:

"react": "17.0.1",
"react-native": "0.64.0"
"node": v14.8.0

Steps to reproduce

I am unable to reproduce this error in debug or in all release versions.
This only happens for a small set of our users, 155 users so far, with 1.2K events count.

From StackOverflow
Below linked SO answer seems to be almost similar issue to this.
But in RN 64, okhttp 4.x is already installed I guess and I have no messed with any of its dependencies.
https://stackoverflow.com/questions/63365254/okhttp-error-during-react-navtive-get-request

Additional Info

This is the only occurrence of okhttp in my entire codebase. This was added while using RN Upgrade Helper to upgrade from RN 62.2 to 64.0 version. I am not sure if this is any cause for the issue above.

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
@stigi
Copy link
Contributor

stigi commented May 4, 2021

I worked around this by forcing all versions to 3.12.12 which is the version that is used internally by react-native 0.64.0:

OKHTTP_VERSION=3.12.12

In the meantime it was bumped twice though, once to 3.14.9 in #30609 to address some security concerns and once to 4.9.0 in #31084.

The workaround (would love to hear other folks opinion) is adding this in dependencies in android/app/build.gradle:

configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.12.12' }

@HishamMubarak
Copy link
Author

@stigi , thank you for the response. I will test this our in an upcoming test version and see how it goes.

Will update you with the result.

@HishamMubarak
Copy link
Author

I worked around this by forcing all versions to 3.12.12 which is the version that is used internally by react-native 0.64.0:

OKHTTP_VERSION=3.12.12

In the meantime it was bumped twice though, once to 3.14.9 in #30609 to address some security concerns and once to 4.9.0 in #31084.

The workaround (would love to hear other folks opinion) is adding this in dependencies in android/app/build.gradle:

configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.12.12' }

Hi, I released an update with the changes you proposed and things seems to have fixed.
Thanks a lot for your help, much appreciated :)

@stigi
Copy link
Contributor

stigi commented Jun 29, 2021

Heads up, react-native v0.65 will have #31084 merged. It is advisable to remove that workaround when upgrading. In our case it is even necessary to prevent crashes.

@HishamMubarak
Copy link
Author

Heads up, react-native v0.65 will have #31084 merged. It is advisable to remove that workaround when upgrading. In our case it is even necessary to prevent crashes.

Thanks a lot for the heads up. Will make sure to revert it back once v65 is stable.

@facebook facebook locked as resolved and limited conversation to collaborators May 14, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants