gradle - Error while compiling React-native duplicate entry: javax/inject/Inject.class -
i downloaded react-native project web called react-native-obd2. before got started wanted run example given in repo while running react-native run-android
getting stuck @ error.
:app:transformclasseswithjarmergingfordebug failed failure: build failed exception. * went wrong: execution failed task ':app:transformclasseswithjarmergingfordebug'. > com.android.build.api.transform.transformexception: java.util.zip.zipexception: duplicate entry: javax/inject/inject.class
i have been breaking head on 3 hours solve bugger wouldn't go.
i have tried various solutions 1 of logical solution me javax/inject/inject.class
being called twice somewhere.
so typed command gradle classpath.
./gradlew -q dependencies app:dependencies --configuration compile
compile - classpath compiling main sources. +--- project :react-native-obd2 | +--- com.android.support:appcompat-v7:23.0.1 -> 24.1.0 | | +--- com.android.support:animated-vector-drawable:24.1.0 | | | \--- com.android.support:support-vector-drawable:24.1.0 | | | \--- com.android.support:support-v4:24.1.0 | | | \--- com.android.support:support-annotations:24.1.0 | | +--- com.android.support:support-v4:24.1.0 (*) | | \--- com.android.support:support-vector-drawable:24.1.0 (*) | +--- com.facebook.react:react-native:+ -> 0.34.1 | | +--- javax.inject:javax.inject:1 | | +--- com.android.support:appcompat-v7:23.0.1 -> 24.1.0 (*) | | +--- com.android.support:recyclerview-v7:23.0.1 -> 24.1.0 | | | +--- com.android.support:support-v4:24.1.0 (*) | | | \--- com.android.support:support-annotations:24.1.0 | | +--- com.facebook.fresco:fresco:0.11.0 | | | +--- com.facebook.fresco:drawee:0.11.0 | | | | +--- com.android.support:support-v4:23.2.1 -> 24.1.0 (*) | | | | \--- com.facebook.fresco:fbcore:0.11.0 | | | +--- com.facebook.fresco:fbcore:0.11.0 | | | \--- com.facebook.fresco:imagepipeline:0.11.0 | | | +--- com.android.support:support-v4:23.2.1 -> 24.1.0 (*) | | | +--- com.facebook.fresco:fbcore:0.11.0 | | | +--- com.parse.bolts:bolts-tasks:1.4.0 | | | +--- com.nineoldandroids:library:2.4.0 | | | \--- com.facebook.fresco:imagepipeline-base:0.11.0 | | | +--- com.android.support:support-v4:23.2.1 -> 24.1.0 (*) | | | +--- com.facebook.fresco:fbcore:0.11.0 | | | +--- com.parse.bolts:bolts-tasks:1.4.0 | | | \--- com.nineoldandroids:library:2.4.0 | | +--- com.facebook.fresco:imagepipeline-okhttp3:0.11.0 | | | +--- com.facebook.fresco:fbcore:0.11.0 | | | +--- com.squareup.okhttp3:okhttp:3.0.1 -> 3.4.1 | | | | \--- com.squareup.okio:okio:1.9.0 | | | \--- com.facebook.fresco:imagepipeline:0.11.0 (*) | | +--- com.facebook.soloader:soloader:0.1.0 | | +--- com.fasterxml.jackson.core:jackson-core:2.2.3 | | +--- com.google.code.findbugs:jsr305:3.0.0 | | +--- com.squareup.okhttp3:okhttp:3.4.1 (*) | | +--- com.squareup.okhttp3:okhttp-urlconnection:3.4.1 | | | \--- com.squareup.okhttp3:okhttp:3.4.1 (*) | | +--- com.squareup.okhttp3:okhttp-ws:3.4.1 | | | \--- com.squareup.okhttp3:okhttp:3.4.1 (*) | | +--- com.squareup.okio:okio:1.9.0 | | \--- org.webkit:android-jsc:r174650 | +--- com.github.pires:obd-java-api:1.0-rc16 | \--- org.roboguice:roboguice:3.+ -> 3.0.1 +--- project :react-native-vector-icons | \--- com.facebook.react:react-native:+ -> 0.34.1 (*) +--- project :react-native-sp | +--- com.android.support:appcompat-v7:23.0.1 -> 24.1.0 (*) | \--- com.facebook.react:react-native:+ -> 0.34.1 (*) +--- project :react-native-sensor-manager | \--- com.facebook.react:react-native:0.12.+ -> 0.34.1 (*) +--- project :react-native-dialogs | +--- com.facebook.react:react-native:0.20.+ -> 0.34.1 (*) | \--- com.github.afollestad.material-dialogs:commons:0.8.6.2 | +--- com.android.support:appcompat-v7:24.1.0 (*) | \--- com.github.afollestad.material-dialogs:core:0.8.6.2 | +--- com.android.support:appcompat-v7:24.1.0 (*) | +--- com.android.support:recyclerview-v7:24.1.0 (*) | +--- com.android.support:support-v4:24.1.0 (*) | +--- me.zhanghai.android.materialprogressbar:library:1.1.7 | | +--- com.android.support:appcompat-v7:24.0.0 -> 24.1.0 (*) | | \--- com.android.support:support-annotations:24.0.0 -> 24.1.0 | \--- com.android.support:support-annotations:24.1.0 +--- com.android.support:appcompat-v7:23.0.1 -> 24.1.0 (*) \--- com.facebook.react:react-native:+ -> 0.34.1 (*)
but don't see javax written twice. mentioned check versions of downloaded project , file couldn't find significant difference.
here build.gradle
apply plugin: "com.android.application" import com.android.build.outputfile apply from: "../../node_modules/react-native/react.gradle" def enableseparatebuildpercpuarchitecture = false /** * run proguard shrink java bytecode in release builds. */ def enableproguardinreleasebuilds = false android { compilesdkversion 23 buildtoolsversion "23.0.1" defaultconfig { applicationid "com.obd2example" minsdkversion 16 targetsdkversion 22 versioncode 1 versionname "1.0" multidexenabled true ndk { abifilters "armeabi-v7a", "x86" } } splits { abi { reset() enable enableseparatebuildpercpuarchitecture universalapk false // if true, generate universal apk include "armeabi-v7a", "x86" } } buildtypes { release { minifyenabled enableproguardinreleasebuilds proguardfiles getdefaultproguardfile("proguard-android.txt"), "proguard-rules.pro" } } // applicationvariants e.g. debug, release applicationvariants.all { variant -> variant.outputs.each { output -> // each separate apk per architecture, set unique version code described here: // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits def versioncodes = ["armeabi-v7a":1, "x86":2] def abi = output.getfilter(outputfile.abi) if (abi != null) { // null universal-debug, universal-release variants output.versioncodeoverride = versioncodes.get(abi) * 1048576 + defaultconfig.versioncode } } } } repositories { maven { url "https://jitpack.io" } } dependencies { compile project(':react-native-obd2') compile project(':react-native-vector-icons') compile project(':react-native-sp') compile project(':react-native-sensor-manager') compile project(':react-native-dialogs') compile filetree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // node_modules } // run once able run application buck // puts compile dependencies folder libs buck use task copydownloadabledepstolibs(type: copy) { configurations.compile 'libs' }
could please guide me look?
edit 1
in quest find out javax.inject module used twice did grep -r "javax.inject" in node_modules folder , found this
react-native/android/com/facebook/react/react-native/0.34.1/react-native-0.34.1.pom: <groupid>javax.inject</groupid> react-native/android/com/facebook/react/react-native/0.34.1/react-native-0.34.1.pom: <artifactid>javax.inject</artifactid> react-native/reactandroid/src/main/third-party/java/jsr-330/buck: url = 'mvn:javax.inject:javax.inject:jar:1', react-native/reactandroid/src/main/java/com/facebook/react/coremodulespackage.java:import javax.inject.provider; react-native/reactandroid/src/main/java/com/facebook/react/bridge/modulespec.java:import javax.inject.provider; react-native/reactandroid/src/main/java/com/facebook/react/shell/mainreactpackage.java:import javax.inject.provider; react-native/reactandroid/build.gradle: compile 'javax.inject:javax.inject:1'
is there wrong here? not versed java , gradle build system comprehend it.
in build.gradle
file, can try changing following line:
compile "com.facebook.react:react-native:+" // node_modules
to this:
compile("com.facebook.react:react-native:+") { exclude module: 'javax.inject' }
the error mean @inject
annotation being included in final apk multiple times , it's coming different places. it's hard pinpoint where, transitive dependency react-native 1 of sources. excluding leave 1 "copy" of in final apk.
Comments
Post a Comment