gradlew buildRelease don't build my app because of an issue with async-storage.
It should build without errors.
I added this library on my project.
D8: Program type already present: com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil
FAILURE: Build failed with an exception.
Is AsyncStorage linked manually? Have you tried to clean and rebuild? Or try to disable R8 to see if it can build without it?
Is
AsyncStoragelinked manually? Have you tried to clean and rebuild? Or try to disable R8 to see if it can build without it?
@Krizzu thank you for your reply.
I solved it. At the time I installed this package at first I linked it manually, then, I unlinked it via react-native unlink @react-native-community/async-storage.
But I found out there were still some references in settings.gradle and build.gradle, I removed them and now it works fine!
If i unlink i get error that async storage is not linked
I still get the same error even after I ran
react-native unlink @react-native-community/async-storageEnvironment
"react-native": "0.62.2"
"@react-native-community/async-storage": "^1.11.0"
Error
> ./gradlew assembleRelease
.....
.....
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.
Program type already present: com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil
@focalsolution You should not have AsyncStorage entries (or any other auto-linkable libraries) in gradle.settings/build.gradle. Remove those and retry
@Krizzu Can you guide me how to know if any auto-link libraries in node_modules contain this AsyncStorage?
@Krizzu I figured it out and solved by excluding AsyncStorage from jitsi library.
Thanks a lot for your reply that can shed me some light.
I add these lines in the app/build.gradle
+ implementation (project(':react-native-jitsi-meet')) {
+ exclude group: 'com.facebook.react', module:'react-native-community-async-storage'
+ }
Uninstall async Storage it would work fine!
Most helpful comment
@Krizzu thank you for your reply.
I solved it. At the time I installed this package at first I linked it manually, then, I unlinked it via
react-native unlink @react-native-community/async-storage.But I found out there were still some references in
settings.gradleandbuild.gradle, I removed them and now it works fine!