Vydia / react-native-background-upload

Upload files in your React Native app even while it's backgrounded. Supports Android and iOS, including camera roll assets.
MIT License
723 stars 330 forks source link

FATAL EXCEPTION: OkHttp Dispatcher #220

Closed matamicen closed 3 years ago

matamicen commented 3 years ago

Hi guys, First of all thanks for this library :)

As soon we installed the latest version of this library (6.2.0) the app crashes and the log throws:

 E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.mqreobxc, PID: 902
    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/com.mqreobxc-pjTGFWZTq6IKd0DOql_nDw==/base.apk!classes3.dex)

We are using RN 063.2 and the only library that use okhttp seems to be Flipper, which is installed by default in this RN version but we are not using it, and here is the only code that we found okhttp is in build.gradle:

dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
        //noinspection GradleDynamicVersion
        implementation "com.facebook.react:react-native:+"  // From node_modules

        implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
        debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
            exclude group:'com.facebook.fbjni'
        }
        debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
            exclude group:'com.facebook.flipper'
            exclude group:'com.squareup.okhttp3', module:'okhttp'
        }
        debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
            exclude group:'com.facebook.flipper'
        }

Any help will be appreciated.

Thanks @StevePotter

reime005 commented 3 years ago

@matamicen can you try with these two additions? implementation 'com.squareup.okhttp3:okhttp:3.2.1' and implementation 'com.squareup.okhttp3:okhttp:4.4.1'

matamicen commented 3 years ago

@reime005 Thanks for your soon answer :)

Where exactly do I have to add implementation 'com.squareup.okhttp3:okhttp:3.2.1' and implementation 'com.squareup.okhttp3:okhttp:4.4.1' ?

Thanks.

reime005 commented 3 years ago

@matamicen to your app's android/app/build.gradle dependencies

matamicen commented 3 years ago

@reime005 good news!

it was a RN thing so nothing wrong with this library, the app was crashing when I call a simple FETCH, so we had to add this to the dependencies and everything is working now, it seems that happens with okhttp above version 4 which is the version that use this library on version above 6.0.0 thru android-upload-service :)

    implementation "com.squareup.okhttp3:okhttp:4.4.1"
    implementation "com.squareup.okhttp3:logging-interceptor:4.4.1"
    implementation "com.squareup.okhttp3:okhttp-urlconnection:4.4.1"

here is the link, may be it helps someone.

I have another question with this library that may be you can help me again :) but I am going to open a new issue, so I will close this one.

Thanks again!!