Jitsi-meet: [Android] Crash caused by NoSuchMethodError if OkHttp is added as dependency

Created on 16 Oct 2020  路  6Comments  路  Source: jitsi/jitsi-meet

Description:

Adding com.squareup.okhttp3 to an android app with JitsiMeet causes a crash.
The crash previously didn't happen and has only started recently.

The app I'm working on uses these versions:

com.squareup.okhttp3:logging-interceptor:4.8.0
org.jitsi.react:jitsi-meet-sdk:2.9.0

The crash still occurs on the latest versions:

org.jitsi.react:jitsi-meet-sdk:2.10.0
com.squareup.okhttp3:logging-interceptor:4.9.0

Steps to reproduce:

  1. Add implementation "com.squareup.okhttp3:okhttp:4.9.0" to the Kotlin sample app.
  2. Run the app and try to join a room.

Actual behavior:

Crash from the sample app. org.jitsi.react:jitsi-meet-sdk:2.10.0 and com.squareup.okhttp3:logging-interceptor:4.9.0

2020-10-16 16:29:47.608 8687-9737/net.jitsi.sdktest E/JitsiMeetSDK: JitsiMeetUncaughtExceptionHandler FATAL ERROR
    java.lang.NoSuchMethodError: 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 /data/app/net.jitsi.sdktest-jgIWMkCbwMhfqJgMlgFZOA==/base.apk!classes3.dex)
        at okhttp3.JavaNetCookieJar.decodeHeaderAsJavaNetCookies(JavaNetCookieJar.java:91)
        at okhttp3.JavaNetCookieJar.loadForRequest(JavaNetCookieJar.java:74)
        at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest(ReactCookieJarContainer.java:43)
        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)

Crash from a different app. com.squareup.okhttp3:logging-interceptor:4.8.0 and org.jitsi.react:jitsi-meet-sdk:2.9.0

2020-10-16 16:05:49.335 2835-5110/com.app.app E/JitsiMeetSDK: JitsiMeetUncaughtExceptionHandler FATAL ERROR
    java.lang.NoSuchMethodError: No virtual method toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super classes (declaration of 'okhttp3.Cookie' appears in /data/app/com.app.app-yNgiyFZysSjxgqHj2FecXQ==/base.apk!classes3.dex)
        at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45)
        at com.facebook.react.modules.network.ReactCookieJarContainer.saveFromResponse(ReactCookieJarContainer.java:36)
        at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85)
        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)

Additional information

Here are some of the logs from JitsiMeetSDK from before the crash.

[features/base/media] Start audio only set to false
ExternalAPI Sending event: CONFERENCE_WILL_JOIN with data: { NativeMap: {"url":"https://meet.jit.si/gbe45y3f2465hni"} }
Conference will join: {url=https://meet.jit.si/gbe45y3f2465hni}
[modules/xmpp/xmpp.js] P2P STUN servers:  [ { urls: 'stun:stun.l.google.com:19302' },
      { urls: 'stun:stun1.l.google.com:19302' },
      { urls: 'stun:stun2.l.google.com:19302' } ]
[modules/xmpp/xmpp.js] (TIME) Strophe connecting:    1602855924186
[features/analytics] Loaded 0 analytics handlers
[modules/RTC/RTCUtils.js] Get media constraints { audio: true, video: false }
[modules/RTC/RTCUtils.js] Get media constraints { audio: false,
      video: 
       { mandatory: { minWidth: 1280, minHeight: 720, maxWidth: 1280, maxHeight: 720 },
         optional: [ [Object] ],
         facingMode: 'user',
         width: { ideal: 1280 },
         height: { ideal: 720 } } }
[modules/statistics/AnalyticsAdapter.js] Disposing of analytics adapter.
[features/calendar-sync] Calendar access not granted.
[modules/RTC/RTCUtils.js] Available devices:  [ { kind: 'videoinput',
        label: '0',
        groupId: '',
        deviceId: '0',
        facing: 'environment' },
      { kind: 'videoinput',
        label: '1',
        groupId: '',
        deviceId: '1',
        facing: 'front' },
      { kind: 'audioinput',
        label: 'Audio',
        groupId: '',
        deviceId: 'audio-1' } ]
[modules/RTC/RTCUtils.js] onUserMediaSuccess
[modules/RTC/JitsiLocalTrack.js] Setting new MSID: e32f5cde-b37a-44ce-9a22-ac2487dd8f88 a81d7096-6b22-436e-b2b1-9d6f954223d4 on LocalTrack[undefined,audio]
[modules/RTC/RTCUtils.js] onUserMediaSuccess
[modules/RTC/JitsiLocalTrack.js] Setting new MSID: d77923a6-26d7-45b2-a4be-c07376c7916f 7938eda4-0ca3-4969-adaa-71be4f771285 on LocalTrack[undefined,video]
2020-10-16 16:45:24.541 1758-13591/? E/ScreenModeService: getAppToken AppWindowToken{d8b8747 token=Token{e013286 ActivityRecord{3279761 u0 net.jitsi.sdktest/org.jitsi.meet.sdk.JitsiMeetActivity t2613}}}
2020-10-16 16:45:24.541 1758-13591/? E/ScreenModeService: setRefreshRate token AppWindowToken{d8b8747 token=Token{e013286 ActivityRecord{3279761 u0 net.jitsi.sdktest/org.jitsi.meet.sdk.JitsiMeetActivity t2613}}} rate 1 tmpRate 2
[modules/xmpp/XmppConnection.js] Stream resume enabled, but WebSockets are not enabled
[modules/xmpp/strophe.ping.js] XMPP pings will be sent every 10000 ms
[modules/xmpp/xmpp.js] (TIME) Strophe connected:     1602855925314
[modules/xmpp/xmpp.js] My Jabber ID: [email protected]/m7ealLsW
[modules/xmpp/xmpp.js] JID [email protected]/m7ealLsW using MUC nickname abafde23
[modules/xmpp/ChatRoom.js] Joined MUC as [email protected]/abafde23
[modules/e2eping/e2eping.js] Initializing e2e ping; pingInterval=-1, analyticsInterval=60000.
[modules/connectivity/ParticipantConnectionStatus.js] RtcMuteTimeout set to: 10000
[JitsiConference.js] No VAD Processor was provided. Talk while muted detection service was not initialized!
[JitsiConference.js] No VAD Processor was provided. Noisy microphone detection service was not initialized!
[modules/statistics/AvgRTPStatsReporter.js] Avg RTP stats will be calculated every 15 samples
[JitsiConference.js] backToP2PDelay: 5
[modules/videosipgw/VideoSIPGW.js] creating VideoSIPGW
[JitsiConference.js] _doReplaceTrack - no JVB JingleSession
android mobile

Most helpful comment

Hello @MarkNjunge @pworldx
I found this solution may help you:

Add these dependencies:

api(platform("com.squareup.okhttp3:okhttp-bom:4.8.0"))
api("com.squareup.okhttp3:okhttp")              // No version!
api("com.squareup.okhttp3:logging-interceptor") // No version!

And remove other dependencies related to okhttp3.

All 6 comments

same issue i am facing. App is getting crash after adding com.squareup.okhttp3 in the base project

Hello @MarkNjunge @pworldx
I found this solution may help you:

Add these dependencies:

api(platform("com.squareup.okhttp3:okhttp-bom:4.8.0"))
api("com.squareup.okhttp3:okhttp")              // No version!
api("com.squareup.okhttp3:logging-interceptor") // No version!

And remove other dependencies related to okhttp3.

@GemiDroid
That works but it ends up using okhttp 3.14.9 while my app requires features from 4.0+.

how to solve in gradle 4.0.1 okhttp errorjava.lang.NoSuchMethodError: No virtual method toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super classes (declaration of 'okhttp3.Cookie' appears in /data/app/com.umg.telemedicine_doctor-b2wD7MHXhMin4zYeAsJAgA==/base.apk!classes4.dex) at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45) at com.facebook.react.modules.network.ReactCookieJarContainer.saveFromResponse(ReactCookieJarContainer.java:36) at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502) 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)

how to solve in gradle 4.0.1 okhttp errorjava.lang.NoSuchMethodError: No virtual method toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super classes (declaration of 'okhttp3.Cookie' appears in /data/app/com.umg.telemedicine_doctor-b2wD7MHXhMin4zYeAsJAgA==/base.apk!classes4.dex) at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45) at com.facebook.react.modules.network.ReactCookieJarContainer.saveFromResponse(ReactCookieJarContainer.java:36) at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502) 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)

It seems related to proguard..
You should follow proguard rules to solve, if not show alternative solution:
https://github.com/jitsi/jitsi-meet/issues/7922#issuecomment-710753881

React Native (which our SDK uses) depends on okhttp 3.12. If you use a later version you are in for trouble. Please downgrade until RN themselves update.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kangzhe0000 picture kangzhe0000  路  39Comments

svtagt picture svtagt  路  55Comments

saghul picture saghul  路  106Comments

JpTiger picture JpTiger  路  50Comments

Janhouse picture Janhouse  路  99Comments