No static method delimiterOffset in class Lokhttp3/internal/Util

4.8k views Asked by At

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.

3

There are 3 answers

2
Jesse Wilson On BEST ANSWER

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!
}
2
Reejesh On

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.

0
Pebo Hamza On

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));
    }