Search code examples
androidreact-nativeapk

React Native Error while generating the main dex list


I tried most the answers provided in stackoverflow as well as github from adding

multiDexEnabled true 
dexOptions{javaMaxHeapSize "4g"} 

but there was no luck, I think my problem is with the dependencies. The actual error I am getting when I run cd android ./gradlew clean then gradlew assembldebug or react-native run-android is

What went wrong: Execution failed for task':app:transformClassesWithMultidexlistForDebug'. com.android.build.api.transform.TransformException: Error while generating the main dex list.

Building in Android Studio shows the following Error:

Program type already present: androidx.versionedparcelable.CustomVersionedParcelable

adding

android.useAndroidX=true
android.enableJetifier=true

causes more problems since most of my react-native libraries that I used in my project not translated to androidx

Execution failed for task ':react-native-navigation:compileReactNative57_5DebugJavaWithJavac'

so my intention is to draw back from androidx, is there a way to do so?


Solution

  • After a day of research, couldn't find a correct way to roll back from androidx and translating all react-native dependencies to androidx manually seems a tedious job but thanks to this library jetifier I was able to do so just by running

    npm i --save-dev jetifier
    npx jetify