How to Resolve 'Duplicate Class' Android Build Errors in React Native and Expo
React Native and Expo developers frequently encounter a 'Duplicate class' Gradle build error on Android, typically triggered after installing a new package, upgrading Expo, or changing a dependency. The error occurs when two different libraries include the same compiled Java or Kotlin class, causing Gradle to halt the build rather than guess which version to package. The root cause is usually not the library named in the error message, but a transitive dependency pulling in an older or incompatible version behind the scenes. Common culprits include version mismatches between libraries, outdated third-party packages referencing legacy AndroidX or Google Play Services versions, and manually added Android dependencies that Expo already manages internally. Recommended fixes include identifying the conflicting modules, running Gradle dependency insight commands to trace the source, updating outdated libraries, and clearing the Gradle cache before rebuilding.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in