config-plugins
config-plugins copied to clipboard
Expo 52 build fails on Android when `expo-haptics` is in dependencies (v9.0.0)
Summary
When using Expo 52 with config plugin 9.0.0 and expo-haptic set as separate dependecy in our package.json, the Android build fails because of duplicate classes.
"expo": "~52.0.14",
"expo-haptics": "~14.0.0",
"@config-plugins/react-native-branch": "^9.0.0",
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Type expo.modules.haptics.BuildConfig is defined multiple times: /Users/abc/cde/node_modules/@config-plugins/react-native-branch/android/build/.transforms/a6b533ec208fe16ce95ede06ed3ac2c8/transformed/classes/classes_dex/classes.dex, /Users/abc/cde/node_modules/expo-haptics/android/build/.transforms/a3f17f527daa7622ddc6139fd2503168/transformed/classes/classes_dex/classes.dex
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Adding the following to package.json as a workaround seems to solve the issue:
"expo": {
"autolinking": {
"exclude": [
"expo-haptics"
]
},
},
Config Plugin
@config-plugins/react-native-branch
What platform(s) does this occur on?
Android
SDK Version
52.0.14
Reproducible demo
Create an Expo 52 project, include the packages above, run development Android build
diff --git a/android/build.gradle b/android/build.gradle
index ed48d73185da82aa645bfcfe1ae299df8dbbb61e..0b508bf59b4c1447c884a8116c706dd43ab3cf95 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -11,7 +11,7 @@ useDefaultAndroidSdkVersions()
useExpoPublishing()
android {
- namespace "expo.modules.haptics"
+ namespace "expo.modules.adapters.branch"
defaultConfig {
versionCode 5
versionName '5.0.0'
I used this patch to fix it.
diff --git a/android/build.gradle b/android/build.gradle index ed48d73185da82aa645bfcfe1ae299df8dbbb61e..0b508bf59b4c1447c884a8116c706dd43ab3cf95 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -11,7 +11,7 @@ useDefaultAndroidSdkVersions() useExpoPublishing() android { - namespace "expo.modules.haptics" + namespace "expo.modules.adapters.branch" defaultConfig { versionCode 5 versionName '5.0.0'I used this patch to fix it.
It worked for me. Thank you!
Also for me, thank you 👍
GRANDE
Error stacktrace for searchability
Execution failed for task ':app:mergeLibDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> 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 expo.modules.haptics.BuildConfig is defined multiple times: /home/expo/workingdir/build/node_modules/@config-plugins/react-native-branch/android/build/.transforms/b023ef5dbd49c6d62087afbc6f917fd7/transformed/classes/classes_dex/classes.dex, /home/expo/workingdir/build/node_modules/expo-haptics/android/build/.transforms/79def682dc6d00530eaf9f3b5f56f69b/transformed/classes/classes_dex/classes.dex