7

I am using jitsi library for video connection. It works fine when installed for the first time but it crashes if a user already has application and updates it from play store. Logs from crash says:

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)

There are 2 auto generated files: 1) okhttp3.JavaNetCookieJar 2) okhttp3.internal.Util.

From class JavaNetCookieJar, this delimiterOffset(header, pos, limit, ";,") method is called in Util class.

Util class has delimiterOffset() method not compatible with the one which is called:

delimiterOffset(delimiters: String, startIndex: Int = 0, endIndex: Int = length)

delimiterOffset(delimiter: Char, startIndex: Int = 0, endIndex: Int = length)

Above methods are called there in Util class.

When I hover over JavaNetCookieJar class, it says that it comes from okhttp3-urlconnection-3.12.1 package and when I hover over Util package it says that it's from okhttp-4.8.0. I am using

implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'

Fun fact is even when I am deleting okhttp3 implementation in gradle, these 2 files are unaffected.

Shubham Anand
  • 551
  • 2
  • 7
  • 19

3 Answers3

9

You must use the exact same version of all OkHttp dependencies. You can configure this manually or use the BOM to do it automatically.

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!
}
Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128
0

Check if your gradle has this line:

configurations {
    all*.exclude group: 'com.squareup.okio'
    all*.exclude group: 'com.squareup.okhttp3'
}

If so, just remove it or comment it

configurations {
    //all*.exclude group: 'com.squareup.okio'
    //all*.exclude group: 'com.squareup.okhttp3'
}

Now clean and rebuild the project.

Reejesh
  • 1,745
  • 2
  • 6
  • 15
  • what if i want to exclude this as it may be giving duplicate library error – Sagar Mar 17 '22 at 19:50
  • @ferox147, this might help you https://stackoverflow.com/a/68139550/14784590. One more note : I usually face this issue when there are jar files, try to replace the jar files with implementation if it is available. – Reejesh Apr 04 '22 at 06:28
0

With an exception like this: Stack trace of error

I was able to solve it by commenting out the line in /android/app/build.gradle:

    public void apply(OkHttpClient.Builder builder) {
      // builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
    }