i am working on a react native android project but i am stuck on this error
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: androidx.versionedparcelable.NonParcelField
FAILURE: Build failed with an exception.
i have tried to change multi dex to false in build.gradle
defaultconfig {...
multiDexEnabled false
...}
i dont want to migrate to androidx , i just want to get rid of androidx & this error ; please help me , thanks in advance
Based on my research couldn't not find an easy way or should I say a correct way to draw back from androidx, to solve the above issue just add the following to your gradle.properties
android.useAndroidX=true
android.enableJetifier=true
That might cause another issue like
Execution failed for task ':react-native-navigation:compileReactNative57_5DebugJavaWithJavac'
the reason of this error, if it occured, after migrating your android project to androidx, many of your react-native libraries ship native Java code and have not been updated, updating it manually is tedious, I was able to do so by using this library jetifier simply by running
npm i --save-dev jetifier
npx jetify
In my case there were still some libraries causing some issues such us react-native-fast-image, as a workaround, I created a gradle.properties inside /node_modules/react-native-fast-image/android and deactivated AndroidX and Jetifier for this module:
android.useAndroidX=false
android.enableJetifier=false
The answer that Ahmed posted is a great solution once you've migrated to AndroidX. In my case I found out that only one library in my application was using AndroidX from this thread
In short my solution was to simply yarn upgrade react-native-device-info@latest The app build as expected after rebuilding it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With