I have build the apk of my react native app and installed it on android device. But whenever I try to open the app it shows below errors:
ss1
ss2
Any help or suggestion would be well appreciated.
you can use ./gradlew assembleRelease to generate apk in release mode or ./gradlew bundleRelease to generate the bundle of the app .aab
for more, you can follow this https://reactnative.dev/docs/signed-apk-android#generating-the-release-aab
I follow this steps.
./gradlew clean
./gradlew assembleRelease
and create APK file.
But after launch my mobile.
I have error . keeps Stopping
There might be something else that causing this crash.
Open your Android Studio,
Open logcat and check the errors
project directory: cd android
./gradlew bundleRelease
react-native run-android is working fine, which means dev apk is working on device but, release apk is not build and failed with the above error.
How I can solve this issue?
I am working on react native. When i try to create a build of android using
gradlew assembleRelease
then getting an
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'npx.cmd'' finished with non-zero exit value 1
But when i create a build using below command build succesfully build
gradlew assembleRelease -x bundleReleaseJsAndAssets
But build not run on mobile device as i am opening my app after install it just crashed.
Also when i try to create build on different System (8gm ram) with same code then it creates build with same command and the build will successfully created. Provide me a solution for this,
use cd android
after that use this ./gradlew clean
and for apk ./gradlew assembleRelease -x bundleReleaseJsAndAssets
or use this for aab ./gradlew bundleRelease -x bundleReleaseJsAndAssets
Try these commands and please tell me if it works
For me, I had to run npm run android once and then ./gradlew assembleRelease worked
UPDATE: Run following command and see output log to find the bug
npx 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
Personally, I had to run the app form within Android Studio.
That gave me a clearer error message which allowed me to fix the issue.
The error in my case had to do with entryFile: "index.android.js", inside app/build.gradle.
I had to change it to index.js since that was the entry point in my RN project.
I try to get apk of app. I did it before well. However, I tried to use get apk of other app today but it doesnt give me release apk. why ?
I followed these steps : enter link description here
Normally, it takes 2-3 minutes but now it lasts just 3 sec and doesnt generate apk
it says this :
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 6.0. Use '--warning-mode all' to show the
individual deprecation warnings. See
https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
I had the same problem. Following command worked for me:
After the ./gradlew bundleRelease command we get a .aab version of our app. To get APK, you should run the app with release version on any device with the below command.
Make sure you have connected an android device
For the production ready app, firstly you have to remove the previous app from the device
Run this command in your-project/:
react-native run-android --variant=release
Then APK can be found in android/app/build/outputs/apk/release
Hope this helps
the short answer uses gradlew assembleRelease instead.
not short answer :) The command you are using gradlew bundleRelease builds an android App bundle. read this:
Difference between apk (.apk) and app bundle (.aab)
and this:
https://developer.android.com/guide/app-bundle
AAB file is new and not all stores support it.
Use gradlew bundleRelease to generate an app bundle (.aab file) and gradlew assembleRelease to generate an apk (.apk file). To install a release on your emulator, use react-native run-android --variant=release. I hope this helps
Cutting the long story short the command gradlew bundleRelease is used to generate an .aab file where as the command gradlew assembleRelease is used to generate .apk file so use the command accordingly
I made a file that called build.sh.
When i want to release a new version of android in ReactNative, just type and press sh ./build.sh in terminal.
My shell script in build.sh file:
npx jetify && cd android && ./gradlew clean && ./gradlew assembleRelease && ./gradlew bundleRelease && cd ..
You can simply open the Build Variants window on the bottom left hand corner of Android Studio and choose release as the current variant:
The following should solve your issue:
Open Android Studio and select "build bundle(s)" from Build/Build Bundle(s)/Apk(s)
Then, open your console and run
cd android && ./gradlew bundleRelease
from your project's root. You may encounter an error such as
Cannot add task 'wrapper' as a task with that name already exists., because overriding built-in tasks are deprecated in 4.8 and produces an error.
To prevent it, please update your android/build.gradle, as follows:
FROM:
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
TO:
wrapper {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
Lastly, don't forget to convert your .aab file to .apk through bundletool in order to test locally your app (exactly as an APK file)
step - 1) ./gradlew bundleRelease
step - 2) react-native run-android --variant=release
Make sure you have connected an android device
For the production-ready app, firstly you have to remove the previous app from the device
./gradlew app:bundleRelease Will fix your problem for sure.