Async-storage: defined multiple times

Created on 18 Jun 2020  路  12Comments  路  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

Already did ./gradlew clean

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

Adding this line fixed my problem exclude group: 'com.facebook.react',module:'react-native-community-async-storage' within react-natvie-jitsi-meet. So it was more a problem because of that dependency.

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

All 12 comments

Seems like Gradle issue or Async Storage added twice somehow. Did you try removing node_modules and installing them again?

Yes i know, it does look that way. Is it possible that another dependency also makes use of async storage and that that is the conflict here? And yes i did remove the node_modules map already.

Yes i know, it does look that way. Is it possible that another dependency also makes use of async storage and that that is the conflict here? And yes i did remove the node_modules map already.

I don't see third party involved here:

/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

With RN 0.62, I believe you let auto-linking link the library for you? What about removing node_modules/@react-native-community/async-storage/android/build and /my-app/android/app/build by hand and trying again?

I did use auto-linking yes.
Removing those folders by hand and building bundle release failed again. Same error.

I think i had something similar a time before with a other dependency and had to do this:

implementation(project(':react-native-jitsi-meet')) {
      exclude group: 'com.facebook.react',module:'react-native-locale-detector'
      exclude group: 'com.facebook.react',module:'react-native-vector-icons'
    }

(at the end of the page of https://github.com/skrafft/react-native-jitsi-meet)

That's very possible that one of your native dependency lib has dependency on AsyncStorage (and include it in their build), hence collision (which is really uncool for the lib itself - it should mention that it requires AS as dependency and should be added by user).

Adding this line fixed my problem exclude group: 'com.facebook.react',module:'react-native-community-async-storage' within react-natvie-jitsi-meet. So it was more a problem because of that dependency.

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

Glad you have it worked out.

@RicardoDolNL this issue is fixed i thing but it is giving another error like below. If you have any idea please tell me.

Type co.apptailor.googlesignin.BuildConfig is defined multiple times: /Users/ansh/Documents/ANSH/FitnerApp/node_modules/@react-native-community/google-signin/android/build/.transforms/985c9104e7fdec208675d8ebe3e42604/classes/classes.dex, /Users/ansh/Documents/ANSH/FitnerApp/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes.dex

@RicardoDolNL When I exclude AsyncStorage, the Release can build properly. However, jitsi will throw exception at runtime. For example, when it tried to open Video call.

Not quite sure if you face similar issue and how you resolved it.
Can you shine me some light?

@RicardoDolNL this issue is fixed i thing but it is giving another error like below. If you have any idea please tell me.

Type co.apptailor.googlesignin.BuildConfig is defined multiple times: /Users/ansh/Documents/ANSH/FitnerApp/node_modules/@react-native-community/google-signin/android/build/.transforms/985c9104e7fdec208675d8ebe3e42604/classes/classes.dex, /Users/ansh/Documents/ANSH/FitnerApp/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes.dex

Sounds like a similar problem. You cloud try also excluding it, something like this:
exclude group: 'com.facebook.react',module:'react-native-community-google-signin'

But i don't know if it's a conflict with jitsi-meet, so you might need to exclude it for an other implementation.
I also saw somewhere that settting multiDexEnabled to true (in app/build.gradle defaultConfig) might also fix it.

defaultConfig {
        ...the rest of you default config
        multiDexEnabled true
    }

@RicardoDolNL When I exclude AsyncStorage, the Release can build properly. However, jitsi will throw exception at runtime. For example, when it tried to open Video call.

Not quite sure if you face similar issue and how you resolved it.
Can you shine me some light?

As far as i know i didn't had that problem. You might want to ask around at https://github.com/skrafft/react-native-jitsi-meet for that (since i'm guessing you're using that dependancy?)

Had the same issue, I unlinked the package react-native unlink @react-native-community/async-storage, upgraded it to the latest version, rebuilt my project Build > Rebuild Project. Runs perfectly now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cpojer picture cpojer  路  34Comments

sumanthyedoti picture sumanthyedoti  路  25Comments

loic-lopez picture loic-lopez  路  37Comments

burhanahmed92 picture burhanahmed92  路  27Comments

josmithua picture josmithua  路  20Comments