React-native-background-geolocation: Android error duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class

Created on 18 Sep 2017  路  13Comments  路  Source: transistorsoft/react-native-background-geolocation

Your Environment

  • Plugin version:^2.9.3
  • Platform: Android
  • OS version: 7.0
  • Device manufacturer / model:lenovo k6 power
  • React Native version (react-native -v):0.44.0
  • Plugin config

Expected Behavior


Before one week ago it's working fine but when i have reinstalled package it's showing this error

Actual Behavior


it should work as expected

Steps to Reproduce


1.install package
2.react-native run-android

Context

Debug logs

  • What went wrong:
    Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
  • com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class

    • Try:
      Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    help wanted

    Most helpful comment

    Now change that back to what it was (3.8.1)

    In build.gradle (Module: app), modify as follows:

    dependencies {
    +    compile(project(':react-native-background-geolocation') ) {
    +        exclude group: 'com.squareup.okhttp3'
    +    }
    +    compile ('com.squareup.okhttp3:okhttp:3.4.1') {
    +        force = true;
    +    }    
    

    All 13 comments

    I recently upgraded the plugin's http service to use the more modern OkHttp instead of Volley.

    However, RN also uses OkHttp in the dev server.

    an older version of OkHttp is used in that version of RN you're using (0.44.0) while the plugin is using the most recent version.

    You can either upgrade to latest RN or provide or override the version of okhttp3 in your app/build.grade

    @christocracy can you please tell me the last version of okhttp3 which was working

    The plugin is using 3.8.1

    @christocracy how can i override this i am new to react-native

    show me the result of:

    $ cd android
    $ ./gradlew app:dependencies
    
    compile - Classpath for compiling the main sources.
    +--- project :react-native-background-geolocation
    |    +--- com.facebook.react:react-native:+ -> 0.44.0
    |    |    +--- javax.inject:javax.inject:1
    |    |    +--- com.android.support:appcompat-v7:23.0.1
    |    |    |    \--- com.android.support:support-v4:23.0.1 -> 25.2.0
    |    |    |         +--- com.android.support:support-compat:25.2.0
    |    |    |         |    \--- com.android.support:support-annotations:25.2.0
    |    |    |         +--- com.android.support:support-media-compat:25.2.0
    |    |    |         |    +--- com.android.support:support-annotations:25.2.0
    |    |    |         |    \--- com.android.support:support-compat:25.2.0 (*)
    |    |    |         +--- com.android.support:support-core-utils:25.2.0
    |    |    |         |    +--- com.android.support:support-annotations:25.2.0
    |    |    |         |    \--- com.android.support:support-compat:25.2.0 (*)
    |    |    |         +--- com.android.support:support-core-ui:25.2.0
    |    |    |         |    +--- com.android.support:support-annotations:25.2.0
    |    |    |         |    \--- com.android.support:support-compat:25.2.0 (*)
    |    |    |         \--- com.android.support:support-fragment:25.2.0
    |    |    |              +--- com.android.support:support-compat:25.2.0 (*)
    |    |    |              +--- com.android.support:support-media-compat:25.2.0 (*)
    |    |    |              +--- com.android.support:support-core-ui:25.2.0 (*)
    |    |    |              \--- com.android.support:support-core-utils:25.2.0 (*)
    |    |    +--- com.facebook.fbui.textlayoutbuilder:textlayoutbuilder:1.0.0
    |    |    |    \--- com.facebook.fbui.textlayoutbuilder:staticlayout-proxy:1.0
    |    |    +--- com.facebook.fresco:fresco:1.0.1
    |    |    |    +--- com.facebook.fresco:drawee:1.0.1
    |    |    |    |    \--- com.facebook.fresco:fbcore:1.0.1
    |    |    |    +--- com.facebook.fresco:fbcore:1.0.1
    |    |    |    \--- com.facebook.fresco:imagepipeline:1.0.1
    |    |    |         +--- com.parse.bolts:bolts-tasks:1.4.0
    |    |    |         +--- com.facebook.fresco:fbcore:1.0.1
    |    |    |         \--- com.facebook.fresco:imagepipeline-base:1.0.1
    |    |    |              +--- com.parse.bolts:bolts-tasks:1.4.0
    |    |    |              \--- com.facebook.fresco:fbcore:1.0.1
    |    |    +--- com.facebook.fresco:imagepipeline-okhttp3:1.0.1
    |    |    |    +--- com.squareup.okhttp3:okhttp:3.0.1 -> 3.8.1
    |    |    |    |    \--- com.squareup.okio:okio:1.13.0
    |    |    |    +--- com.facebook.fresco:fbcore:1.0.1
    |    |    |    \--- com.facebook.fresco:imagepipeline:1.0.1 (*)
    |    |    +--- com.facebook.soloader:soloader:0.1.0
    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
    |    |    +--- com.squareup.okhttp3:okhttp:3.4.1 -> 3.8.1 (*)
    |    |    +--- com.squareup.okhttp3:okhttp-urlconnection:3.4.1
    |    |    |    \--- com.squareup.okhttp3:okhttp:3.4.1 -> 3.8.1 (*)
    |    |    +--- com.squareup.okhttp3:okhttp-ws:3.4.1
    |    |    |    \--- com.squareup.okhttp3:okhttp:3.4.1 -> 3.8.1 (*)
    |    |    +--- com.squareup.okio:okio:1.9.0 -> 1.13.0
    |    |    \--- org.webkit:android-jsc:r174650
    |    +--- com.google.android.gms:play-services-location:+ -> 11.0.2
    |    |    +--- com.google.android.gms:play-services-base:11.0.2
    |    |    |    +--- com.google.android.gms:play-services-basement:11.0.2
    |    |    |    |    \--- com.android.support:support-v4:25.2.0 (*)
    |    |    |    \--- com.google.android.gms:play-services-tasks:11.0.2
    |    |    |         \--- com.google.android.gms:play-services-basement:11.0.2 (*)
    |    |    +--- com.google.android.gms:play-services-basement:11.0.2 (*)
    |    |    \--- com.google.android.gms:play-services-tasks:11.0.2 (*)
    |    +--- org.greenrobot:eventbus:3.0.0
    |    +--- com.squareup.okhttp3:okhttp:3.8.1 (*)
    |    +--- :tslocationmanager:
    |    +--- org.slf4j:slf4j-api:1.7.21
    |    +--- com.github.tony19:logback-android-core:1.1.1-6
    |    \--- com.github.tony19:logback-android-classic:1.1.1-6
    |         +--- com.github.tony19:logback-android-core:1.1.1-6
    |         \--- com.github.tony19:apktool-lib:1.4.4-3
    +--- :tslocationmanager:
    +--- project :react-native-app-settings
    |    \--- com.facebook.react:react-native:+ -> 0.44.0 (*)
    +--- project :react-native-android-location-heartbeat
    |    +--- com.facebook.react:react-native:0.19.+ -> 0.44.0 (*)
    |    \--- com.drewnoakes:metadata-extractor:2.9.1
    |         \--- com.adobe.xmp:xmpcore:5.1.2
    +--- project :react-native-android-zxing-barcode-scanner
    |    +--- com.facebook.react:react-native:0.19.+ -> 0.44.0 (*)
    |    +--- com.drewnoakes:metadata-extractor:2.9.1 (*)
    |    \--- com.journeyapps:zxing-android-embedded:3.5.0
    |         +--- com.google.zxing:core:3.3.0
    |         \--- com.android.support:support-v4:25.1.0 -> 25.2.0 (*)
    +--- project :react-native-android-location-services-dialog-box
    |    \--- com.facebook.react:react-native:+ -> 0.44.0 (*)
    +--- project :react-native-version-check
    |    \--- com.facebook.react:react-native:0.20.+ -> 0.44.0 (*)
    +--- project :react-native-ble-manager
    |    \--- com.facebook.react:react-native:[0.30.0,) -> 0.44.0 (*)
    +--- project :react-native-beacons-manager
    |    +--- com.facebook.react:react-native:0.12.+ -> 0.44.0 (*)
    |    \--- org.altbeacon:android-beacon-library:2.9.2
    +--- project :react-native-signature-capture
    |    +--- com.android.support:appcompat-v7:23.0.0 -> 23.0.1 (*)
    |    \--- com.facebook.react:react-native:0.19.+ -> 0.44.0 (*)
    +--- project :react-native-background-timer
    |    \--- com.facebook.react:react-native:+ -> 0.44.0 (*)
    +--- project :react-native-camera
    |    +--- com.facebook.react:react-native:0.19.+ -> 0.44.0 (*)
    |    +--- com.google.zxing:core:3.2.1 -> 3.3.0
    |    \--- com.drewnoakes:metadata-extractor:2.9.1 (*)
    +--- com.android.support:appcompat-v7:23.0.1 (*)
    +--- com.facebook.react:react-native:+ -> 0.44.0 (*)
    \--- com.android.support:multidex:1.0.1
    

    As a quick test, open your app in Android Studio.

    • Edit the file build.gradle (react-native-background-geolocation)
    • Change the okhttp3 dependency to use 3.4.1
    dependencies {
    +    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    }
    

    @christocracy thanks it's worked...

    @christocracy i have bought this package and it's showing me licence validation failure..

    Now change that back to what it was (3.8.1)

    In build.gradle (Module: app), modify as follows:

    dependencies {
    +    compile(project(':react-native-background-geolocation') ) {
    +        exclude group: 'com.squareup.okhttp3'
    +    }
    +    compile ('com.squareup.okhttp3:okhttp:3.4.1') {
    +        force = true;
    +    }    
    

    Customers are not supposed to use this public repo. You're to use the private repo

    You need to follow the Setup Instructions and add your LICENSE

    @christocracy still getting this licence validation failure even though i have setup private repo..

    The original issue "Android error duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class" is solved. If you have unrelated problems, post a new issue (at the private repo).

    Was this page helpful?
    0 / 5 - 0 ratings