Can't generate signed apk that can be installed directly on device without connecting to the server.The command given in new documentation is
cd android
$ ./gradlew bundleRelease
which will generate .aab file and app-debug.apk only.
can I use the below command to generate apk in react native 0.60-RC? Can't find that command in their updated document.
$ ./gradlew assembleRelease
.aab is a bundle file which can replace release .apk, anw, you can open Android Studio, build a release APK follow Build/Generate Signed Bundle(s)/ APK and tick on APK checkbox
UPDATE
.aab cannot install directly, but if you want to install the app on a real device without a server (node), you can using below way
Step 1:
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
Step 2:
cd android
$ ./gradlew assembleDebug
now the debug APK file includes the bundle server, so you can install it on your real device independently.
Related
I'm struggling with this issue where I can't generate a APK locally with my coded changes in a React Native 0.67.2 project.
I already did run some of those commands down below to generate a new updated bundle:
npx react-native bundle --entry-file index.js --platform android --dev false --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res
But everytime after running npx react-native run-android --variant=release, it installs an older version of my project.
If I just run it as default npx react-native run-android, which is as debug it works perfectly and install the updated version on my emulator.
It doesn't makes any sense to me, what am I doing wrong?
Try using this command to generate a new APK :
cd android && ./gradlew clean assembleRelease -PMYAPP_UPLOAD_STORE_PASSWORD=foo -PMYAPP_UPLOAD_KEY_PASSWORD=foo
And you'll find it in
yourProject/android/app/build/outputs/apk/debug/app-debug.apk
I have a problem installing the Release version of my application.
Before uploading my application to the playstore I wanted to test the debug and release version on my physical and virtual device that I generated with the following commands:
./gradlew assembleDebug
./gradlew assembleRelease
./gradlew bundleRelease
At the time of testing the debug version works correctly on my virtual and physical device using the following command:
npx react-native run-android --variant=debug
The problem starts when I want to test the release on my devices using the following command:
npx react-native run-android --variant=release
The application can be installed on the devices but it cannot be opened. I leave a screenshot of the messages that the console throws when testing the release version, it is worth mentioning that I generated the boundleRelease I uploaded it to the playstore and when I did a closed test, when I installed my app on my device the same thing happened, the Application is installed but cannot be opened.
When starting the execution of the command it shows this:
console messages at startup
At the end of the execution of the command it shows this:
console messages on completion
These are the specifications that I am using
specifications
I have tried this
there are few steps below:
Goto project directory
//write into terminal
cd android.
//clean by writing this.
2=> ./gradlew clean
//come back to project directory
cd..
//write this complete code to the project directory
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/
//write into terminal
cd android
// if you want debug(.apk)
6=> ./gradlew assembleDebug
// if you want in release mode(.apk)
6=> ./gradlew assembleRelease
// if you want in Bundle release(.abb)
6=> ./gradle bundleRelease
finally find and share from below path.
// for debug
android/app/build/outputs/apk/debug/app-debug.apk
// for release
android/app/build/outputs/apk/release/app-release.apk
// for production
android/app/release/app-release.abb
https://stackoverflow.com/a/71602677
https://reactnative.dev/docs/signed-apk-android
Fixed!!!
Maybe it will help someone in the future. Based on this issue: https://github.com/facebook/react-native/issues/33202 which has now been closed I had to update my project to the latest version of react-native available today (0.71.1 ) It is worth mentioning that I was using the version (0.70.6) and the update was done manually using the upgrade-helper: https://react-native-community.github.io/upgrade-helper/ I share the official response that helped me to base myself on the solution: https://github.com/facebook/react-native/issues/33202#issuecomment-1411938054
With this solution I can already generate the release version, test it on my physical or virtual device and even generate the boundleRelease to be able to upload it to the PlayStore and do closed tests. It works correctly with my testers
https://github.com/facebook/react-native/issues/36023
I'm trying to build my react native app but when I run ./gradlew bundleDebug or ./gradlew bundleRelease it says BUILD SUCCESSFUL but there is no APK in build/outputs/apk directory.
How can I build a universal APK from my react native app?
You have to clean the gradle first then run the command ./gradlew bundleRelease
otherwise use following command into your project directory.
1. cd android && ./gradlew clean
2. cd ..
3. npx react-native run-android --variant=release
I am new to react-native and I use expo. If you are new to app react-native development, try installing expo and letting them handle the build process.
How to install expo onto existing react-native project: https://jablog.online/blog/2020/01/22/existing-react-native-project-on-expo/
The problem solved by using ./gradlew assembleeRelease command.
Just try to generate APK from Android Studio. It is the best and the most stable way. You can find lots of articles about generating APK from Android Studio.
If you still want to generate APK from command line here is the command to run:
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 && rm -rf android/app/src/main/res/drawable-* && cd android && ./gradlew assembleRelease
If you need a more detailed article:
https://www.instamobile.io/android-development/generate-react-native-release-build-android/
I used the official documentation of React Native to build apk file. All other procedures worked fine but creating aab file is not working for me. I used the following command
cd android && ./gradlew bundleRelease
But it's not working on Windows. It is just giving me error of ". is not recognized"
to create main js Bundle
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/
and then run cd android && ./gradlew assembleRelease
Below command work perfectly in mac
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle && cd ./android && ./gradlew app:assembleRelease
cd android/
./gradlew bundleRelease
On Windows, you can use the gradlew executable made for Bash, unless you install WSL for Windows (which is highly recommended for many other reasons, so then your ./gradlew would just work in the WSL shell). Without WSL, you need to use the gradlew.bat file instead, which should be in your android folder in your repo as its included in the react native starter files.
From then on, every command you see written with ./gradlew should be replaced with it, e.g. gradlew.bat assembleRelease. Be sure to be in the 'android' folder though.
I tried to get an unsigned APK. I used the following steps
react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
and then
cd android
assembleDebug
and I also tried
cd android
assembleRelease
I get two APKs. the debug APK get an error that the developement server is not found.
So I used the release APK to install on my device but that doesnt work either. I can install the app.
I dont need an sigend APK just a usignes APK for testings.
EDIT: forgot to say that I'm working on Windows.