Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29506

How to fix OKHttp module conflict in Android ReactNative project with third-party SDK?

$
0
0

I'm working on ReactNative project that it have several native dependencies. When we were developing software, we noticed a crash in application. So we released project and launch on real device (XIAOMI Redmi Note 4x) and started to debug the crash and the only message we received was: https://i.stack.imgur.com/8n3Zq.jpg

And our native dependencies was :

implementation project(':@metrixorg_react-native-metrix')
implementation project(':lottie-react-native')
implementation project(':react-native-firebase')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+"  // From node_modules
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'com.android.support:multidex:1.0.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
    transitive = true
}

As you saw the crash log, we found out that it was definitely from this package: :@metrixorg_react-native-metrix.

The first solution was to remove the package, so we did it and the crash was resolved completely.

When we was sure the package have a problem, we tried to exclude group: 'com.squareup.okhttp3' from the package and built it again, unfortunately when ':@metrixorg_react-native-metrix' be in native dependencies, we have crash on different place of the application.

Latest changes in build.gradle dependencies:

dependencies {
    implementation(project(':@metrixorg_react-native-metrix')){
        exclude group: 'com.squareup.okhttp3'
    }
    implementation(project(':lottie-react-native')){
        exclude group: 'com.squareup.okhttp3'
    }
    implementation(project(':react-native-firebase')){
        exclude group: 'com.squareup.okhttp3'
    }
    implementation project(':react-native-vector-icons')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation 'com.android.support:multidex:1.0.3'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
        transitive = true
    }
    //  implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
    //  implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'



    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

Log react-native info:

System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 83.49 MB / 8.00 GB
    Shell: 5.3 - /bin/zsh
Binaries:
    Node: 10.14.1 - /usr/local/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
    iOS SDK:
    Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
    API Levels: 23, 25, 27, 28, 29
    Build Tools: 23.0.1, 25.0.3, 27.0.3, 28.0.2, 28.0.3
    System Images: android-27 | Google Play Intel x86 Atom
IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
    react-native-cli: 2.0.1

Viewing all articles
Browse latest Browse all 29506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>