Async-storage: defined multiple times

Created on 28 May 2020  路  8Comments  路  Source: react-native-async-storage/async-storage

Current behavior

I get a error while building a release for android:
Error: /my-app/node_modules/@react-native-community/async-storage/android/build/.transforms/fc2daeb4ff0db30fd0f1f5e68862f91b/classes/classes.dex, Type com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil is defined multiple times: /my-app/node_modules/@react-native-community/async-storage/android/build/.transforms/fc2daeb4ff0db30fd0f1f5e68862f91b/classes/classes.dex, /my-app/android/app/build/intermediates/external_libs_dex/release/out/classes2.dex

Expected behavior

That I can build my release.

Repro steps

Environment

  • Async Storage version: 1.11.0
  • React-Native version: 0.62.2
  • Platform tested: Android
  • Logs/Error that are relevant:

Most helpful comment

Have you tried to clean build folders, ./gradlew clean?

All 8 comments

Have you tried to clean build folders, ./gradlew clean?

I have migrated from AsyncStorage (react-native) to that, and I needed to do the clean like @Krizzu said.

Thanks

Please reopen if issue still exist

Sorry for the late response, but no ./gradlew clean was the first thing i tried but that does not solve the problem

`Type com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil is defined multiple times: /Users/ansh/Documents/ANSH/FitnerApp/node_modules/@react-native-community/async-storage/android/build/.transforms/a5435cadaa866449cc02394986475e6b/classes/classes.dex, /Users/ansh/Documents/ANSH/FitnerApp/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes2.dex

`
i am also facing this issue when generating apk but app is running well on device in debug mode. Please tell me the solution if you have solved.? Thanks in advance.

@anshumanburman i am also facing same issue . have you found any solution ?

@anshumanburman @HimaniPatelTH the problem for me was that async-storage had a conflict with react-native-jitsi-meet dependency. Not only async-storage but also react-native-svg. So i had to exclude those inside my /app/build.gradle file:

    implementation(project(':react-native-jitsi-meet')) {
        exclude group: 'com.facebook',module:'hermes'
        exclude group: 'com.facebook.react',module:'react-native-svg'
        exclude group: 'com.facebook.react',module:'react-native-community-async-storage'
        transitive = true
    }

    implementation ('org.jitsi.react:jitsi-meet-sdk:2.+') {
        exclude group: 'com.facebook',module:'hermes'
        exclude group: 'com.facebook.react',module:'react-native-svg'
        exclude group: 'com.facebook.react',module:'react-native-community-async-storage'
        transitive = true
    }

This fixed it for me. So you might also have a dependency that already includes async-storage and you might also want to exclude it in the same way. Hope this helps.

@RicardoDolNL i have added dependency as jar file so this solution is not working .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

while-it picture while-it  路  51Comments

Waqas-Jani picture Waqas-Jani  路  28Comments

loic-lopez picture loic-lopez  路  37Comments

cpojer picture cpojer  路  34Comments

josmithua picture josmithua  路  20Comments