0
votes

I have an issue where the release APK build fails.

Background: I had the error: Unable to load script from assets index.android.bundle

The solution I found for that issue was to: 1. (in project directory) mkdir android/app/src/main/assets 2.react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

But then I cannot build the release APK file successfully.

Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeReleaseResources'

...


drawable-mdpi-v4/assets_images_swedenicon] /home/kacey/timeme-app-new/TimeMe/android/app/build/generated/res/react/release/drawable-mdpi/assets_images_swedenicon.png   [drawable-mdpi-v4/assets_images_swedenicon] /home/kacey/timeme-app-new/TimeMe/android/app/src/main/res/drawable-mdpi/assets_images_swedenicon.png: Error: Duplicate resources
[drawable-mdpi-v4/asset

enter image description here

I expect the release APK to build successfully since everything else builds successfully (running the app on emulator and physical device)

3

3 Answers

1
votes

Maybe the way I did it will work for you.

  1. Clean Project
  2. Rebuild project
  3. Sync project with gradle file
1
votes

The solution for me was to delete all the drawable folders after running the command:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
0
votes

It causes because of duplicate resource creation. So, remove all duplicate resources from directory-

/android/app/src/main/res/drawable-

then run the release command. Hope, it will build the production .apk successfully.