Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradlew assembleRelease command in react-native android is not generating the app-release.apk

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.

like image 286
Mayuri Birajdar Avatar asked Jul 14 '17 07:07

Mayuri Birajdar


People also ask

Where is APK file in react native?

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.

What does Gradlew assembleRelease do?

assembleDebug - Assembles all Debug builds. assembleRelease - Assembles all Release builds.


1 Answers

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

like image 181
Indivision Dev Avatar answered Sep 27 '22 23:09

Indivision Dev