Skip to content

Expo 52 build fails on Android when expo-haptics is in dependencies (v9.0.0) #259

@arndtvoges

Description

@arndtvoges

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions