Kacey Okafor
Kacey Okafor

Reputation: 43

Execution failed for task ':app:mergeReleaseResources' after generating bundle files

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)

Upvotes: 0

Views: 1758

Answers (3)

Ali Hasan
Ali Hasan

Reputation: 4353

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.

Upvotes: 0

Kacey Okafor
Kacey Okafor

Reputation: 43

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

Upvotes: 1

hong developer
hong developer

Reputation: 13926

Maybe the way I did it will work for you.

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

Upvotes: 1

Related Questions