I want to generate the unsigned app-release.apk without the react-packager server. I am running the following commands for that.
cd react-native-project-dir
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
After the following command I get the error in command prompt like these:
cd android && gradlew assemblerelease
app:processReleaseManifestessReleaseManifest
:app:processReleaseResources D:\ReactNativeProject\android\app\build\intermediates\res\merged\release\drawable-mdpi-v4\image_background_unique_2.jpg: error: Duplicate file. D:\ReactNativeProject\android\app\build\intermediates\res\merged\release\drawable-mdpi\image_background_unique_2.jpg: Original is here. The version qualifier may be implied. :app:processReleaseResources FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:processReleaseResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt
And I am not able to generate the app-release.apk and not understanding why the image_background_unique_2.jpg file is getting added two times in different folders.
You can find the generated APK at android/app/build/outputs/apk/app-release. apk. This is the actual app, which you can send to your phone or upload to the Google Play Store. Congratulations, you've just generated a React Native Release Build APK for Android.
assembleDebug - Assembles all Debug builds. assembleRelease - Assembles all Release builds.
The issue is that the new version of react-native bundles the assets under /app/build/intermediates/res/merged/release instead of app/src/main/res
To resolve it, this is what I did
rm -rf android/app/src/main/res/drawable-*
Now bundle assets using this command:
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/
Note the updated --assets-dest
in the above command. Assembling the APK worked ok after that!
react-native run-android --variant=release
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