You will have to create a key to sign the apk. Use below to create your key.
keytool -genkey -v -keystore my-app-key.keystore -alias my-app-alias -keyalg RSA -keysize 2048 -validity 10000
then run following command one by ome
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/
cd android && ./gradlew assembleRelease
adb install -r ./app/build/outputs/apk/app-release-unsigned.apk
While your packager is runnning, run this to create offline bundle
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
(You may need to create assets folder manually) This will create an offline bundle file and if you then run:
react-native run-android
It should deploy it your device.
Instead of development version You should build and install production version of app.
For this you should Generating a signing key.
How to Generating Signed APK: https://facebook.github.io/react-native/docs/signed-apk-android.html
Then every time you want to generate a production version of app run this commands at project root directory.
RN < 0.40
react-native run-android --variant=release
RN >= 0.40
react-native run-android --configuration=release
then just run adb install -r ./app/build/outputs/apk/app-release.apk
or copy and past app/build/outputs/apk/app-release.apk
file on you android and install it directly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.