app:assembleRelease failed, conflicting react native netinfo package

using latest react native sdk v2.1.2 and react native calls 1.0.0. i can do development build just fine, but when i try to do app:assembleRelease it gives me an error like below, n this only gives error for android build, ios release build seems to working fine:

> Task :app:mergeDexRelease FAILED
/Users/mike/Desktop/ConsumerApp/node_modules/@react-native-community/netinfo/android/build/.transforms/d5c043e4a6aa052dab014da8b753c90e/classes/classes.dex: D8: Type com.reactnativecommunity.netinfo.BroadcastReceiverConnectivityReceiver$1 is defined multiple times: /Users/mike/Desktop/ConsumerApp/node_modules/@react-native-community/netinfo/android/build/.transforms/d5c043e4a6aa052dab014da8b753c90e/classes/classes.dex, /Users/mike/Desktop/ConsumerApp/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes2.dex
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type com.reactnativecommunity.netinfo.BroadcastReceiverConnectivityReceiver$1 is defined multiple times: /Users/mike/Desktop/ConsumerApp/node_modules/@react-native-community/netinfo/android/build/.transforms/d5c043e4a6aa052dab014da8b753c90e/classes/classes.dex, /Users/mike/Desktop/ConsumerApp/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes2.dex
        at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:132)
        at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:119)
        at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
        at com.android.build.gradle.internal.tasks.DexMergingTaskRunnable.run(DexMergingTask.kt:441)
        at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:242)
        at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:50)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:59)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:59)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:53)
        at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.lang.Thread.run(Thread.java:748)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
        at com.android.tools.r8.utils.W.a(:87)
        at com.android.tools.r8.D8.run(:11)
        at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:117)
        ... 33 more
Caused by: com.android.tools.r8.utils.b: Error: /Users/mike/Desktop/ConsumerApp/node_modules/@react-native-community/netinfo/android/build/.transforms/d5c043e4a6aa052dab014da8b753c90e/classes/classes.dex, Type com.reactnativecommunity.netinfo.BroadcastReceiverConnectivityReceiver$1 is defined multiple times: /Users/mike/Desktop/ConsumerApp/node_modules/@react-native-community/netinfo/android/build/.transforms/d5c043e4a6aa052dab014da8b753c90e/classes/classes.dex, /Users/mike/Desktop/ConsumerApp/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes2.dex
        at Version.fakeStackEntry(Version_2.0.99.java:0)
        at com.android.tools.r8.utils.O0.a(:21)
        at com.android.tools.r8.utils.N0.b(:7)
        at com.android.tools.r8.utils.N0.a(:26)
        at com.android.tools.r8.utils.N0.a(:10)
        at java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:1990)
        at com.android.tools.r8.utils.N0.a(:6)
        at com.android.tools.r8.graph.D0$c.f(:3)
        at com.android.tools.r8.dex.a.a(:83)
        at com.android.tools.r8.dex.a.a(:10)
        at com.android.tools.r8.D8.d(:6)
        at com.android.tools.r8.D8.b(:1)
        at com.android.tools.r8.utils.W.a(:30)
        ... 35 more


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
     Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
     Type com.reactnativecommunity.netinfo.BroadcastReceiverConnectivityReceiver$1 is defined multiple times: /Users/mike/Desktop/ConsumerApp/node_modules/@react-native-community/netinfo/android/build/.transforms/d5c043e4a6aa052dab014da8b753c90e/classes/classes.dex, /Users/mike/Desktop/ConsumerApp/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes2.dex

n this is my current pacakge.json:

{
  "name": "consumer-app",
  "version": "0.5.0",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start --reset-cache",
    "test": "jest",
    "start:android": "adb shell am start -n asia.clik.ConsumerApp.testing/asia.clik.ConsumerApp.MainActivity",
    "start:emulator": "./emulator.sh",
    "android-emulator": "npm run start:emulator && npm run android",
    "android": "ENVFILE=.env.testing react-native run-android --variant=Debug && npm run start:android",
    "ios": "react-native run-ios --scheme='Testing' --configuration='Testing'",
    "ios:device": "react-native run-ios --device",
    "both": "react-native run-ios && react-native run-android",
    "cache-clean": "./cache-clean.sh",
    "git-gc": "./git-gc.sh",
    "android:test": "export ENVFILE=.env.testing && ./bundle-android.sh && cd android && ENVFILE=.env.testing ./gradlew installDebug && cd .. && npm start && npm run start:android",
    "android:test-win": "set ENVFILE=.env.testing && bash ./bundle-android.sh && cd android && set ENVFILE=.env.testing && bash ./gradlew installDebug && cd ..",
    "android:staging": "cd android && ENVFILE=.env.staging ./gradlew installDebug && cd ..",
    "android:stagingRelease": "export ENVFILE=.env.staging && ./bundle-android.sh && cd android && ENVFILE=.env.staging ./gradlew installRelease && cd ..",
    "android:installAndroid": "export ENVFILE=.env.testing && ./bundle-android.sh && cd android && ENVFILE=.env.testing ./gradlew installRelease && cd ..",
    "android:testingRelease": "export ENVFILE=.env.testing && ./bundle-android.sh && cd android && ENVFILE=.env.testing ./gradlew installRelease && cd ..",
    "test:e2e": "detox test",
    "test:e2e:build": "detox build",
    "test:ios-debug": "detox test -c ios.sim.debug",
    "test:android-debug": "detox test -c android.emu.debug",
    "test:android-release": "detox test -c android.emu.release",
    "detox:ios": "detox build -c ios.sim.debug"
  },
  "babel": {
    "presets": [
      "module:metro-react-native-babel-preset"
    ]
  },
  "dependencies": {
    "@cometchat-pro/react-native-calls": "^1.0.0",
    "@cometchat-pro/react-native-chat": "^2.1.2",
    "@mapbox/polyline": "^0.2.0",
    "@react-native-community/async-storage": "1.11.0",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/image-editor": "^2.2.0",
    "@react-native-community/netinfo": "^3.2.1",
    "@react-native-community/push-notification-ios": "^1.6.0",
    "@react-native-community/toolbar-android": "0.1.0-rc.2",
    "@react-native-firebase/app": "^8.4.5",
    "@react-native-firebase/auth": "^9.2.7",
    "@react-native-firebase/database": "^7.5.11",
    "@react-native-firebase/firestore": "^7.8.6",
    "@react-native-firebase/messaging": "^7.8.4",
    "actheme": "0.0.29",
    "axios": "^0.18.1",
    "buffer": "^5.2.1",
    "clik-rn-ekmc-sdk": "github:clik-asia/clik-rn-ekmc-sdk",
    "clikmessengerwrapper": "^1.0.12",
    "dateformat": "^3.0.3",
    "i18n-js": "^3.1.0",
    "moment": "^2.22.2",
    "progress-hud": "^1.1.0",
    "punycode": "^2.1.1",
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-android-sms-listener": "^0.6.0",
    "react-native-camera": "^3.27.0",
    "react-native-config": "^0.11.7",
    "react-native-contacts": "^5.2.0",
    "react-native-date-picker": "^2.7.8",
    "react-native-device-info": "^5.5.6",
    "react-native-draggable-flatlist": "^2.3.2",
    "react-native-fs": "^2.12.0",
    "react-native-gesture-handler": "^1.5.6",
    "react-native-image-picker": "^0.28.0",
    "react-native-keychain": "5.0.1",
    "react-native-maps": "^0.27.1",
    "react-native-markdown-display": "^6.1.4",
    "react-native-mov-to-mp4": "^0.2.2",
    "react-native-nfc-manager": "^2.1.9",
    "react-native-push-notification": "^6.1.1",
    "react-native-reanimated": "^1.7.0",
    "react-native-screens": "^2.0.0-alpha.12",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "9.13.6",
    "react-native-svg-icon": "0.7.0",
    "react-native-system-setting": "^1.7.5",
    "react-native-tab-view": "^2.13.0",
    "react-native-vector-icons": "^6.3.0",
    "react-navigation": "^4.0.10",
    "react-navigation-redux-helpers": "^2.0.8",
    "react-navigation-stack": "^1.9.4",
    "react-redux": "^7.1.1",
    "redux": "^3.7.2",
    "redux-persist": "^5.10.0",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "7.9.6",
    "@babel/runtime": "7.9.6",
    "metro-react-native-babel-preset": "0.58.0",
    "detox": "^16.3.1",
    "jetifier": "^1.6.4",
    "mocha": "^7.1.1",
    "reactotron-apisauce": "^2.1.0",
    "reactotron-react-native": "^2.1.0",
    "reactotron-redux": "^2.1.0"
  },
  "detox": {
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/Consumer.app",
        "build": "xcodebuild -workspace ios/ConsumerApp.xcworkspace -scheme Testing -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "device": {
          "type": "iPhone 11"
        }
      },
      "android.emu.debug": {
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
        "type": "android.emulator",
        "name": "Nexus_5X_API_28"
      },
      "android.emu.release": {
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
        "type": "android.emulator",
        "name": "Nexus_5X_API_28"
      }
    },
    "test-runner": "mocha"
  },
  "xcodeSchemes": {
    "Debug": [],
    "Release": [
      "Testing",
      "Staging",
      "Production"
    ],
    "projectDirectory": "iOS"
  },
  "projectDirectory": "iOS"
}

seems to be a conflicting netinfo package with my main project. i enabled multidex in my app/build.gradle, but still giving me same error:

defaultConfig {
        applicationId "asia.clik.ConsumerApp"
        applicationIdSuffix project.env.get("ENV")
        minSdkVersion 21
        targetSdkVersion 28
        versionCode readVersionCode()
//        project.env.get("CODE").toInteger()
        versionName "${readVersionName()}"
        ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        resValue "string", "build_config_package", "asia.clik.ConsumerApp"
        missingDimensionStrategy 'react-native-camera', 'general'
    }

I have the same issue. More info here https://github.com/cometchat-pro/react-native-chat-sdk/issues/23

Hey guys, took me a while and a few tries but I’ve managed to work around this problem. I’ll post the solution to the githun issue link if you guys still haven’t figured a way around yet :smiley: haven’t been active on this forum lately

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.