How To create debug apk file in react native - react-native

I have a react native project. it works fine on android. but can not create debug apk file of this project.

first run this command in your terminal
npm run 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/
after this go inside your android folder by running this command
cd android && ./gradlew assembleDebug
then you can get your apk from this location
app/build/outputs/apk/debug/app-debug.apk

Related

Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release

I upgraded node and Android studio.
After that when i run the application it's working in simulator but device not working.
it's showing below error,
Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release
1.create directory android/app/src/main/assets
run following command from project root directory
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
------------------------ OR ---------------------
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
run again the command : react-native run-android
Follow below link:
https://www.youtube.com/watch?v=8FEm1SjL1Vg

React native release APK or IPA is not updating according to my code

I have tried making new bundle using command below but still no luck.
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/shell-app.bundle --assets-dest android/app/src/main/res
My app is expo ejected app
I don't know about iOS , but on Android try the following
Clean your build
in your project directory execute
cd android && gradlew clean
Increase your build number.
go to {ProjectDirectory}/android/app/build.gradle
android {
defaultConfig {
versionCode 1 // increase this value by one
}}
finally build your release
in your project directory execute
cd android && gradlew assembleRelease

How to generate the unsigned apk for android - reac-native

I tried to generate an unsigned apk to install on my other device.
I tried
cd android
then
gradlew assembleRelease
I got an "app-release-unsigned.apk" at android\app\build\outputs\apk\release
I transfered this "app-release-unsigned.apk" to my other android device. Turned on the "install unknown apps". Then installed the "app-release-unsigned.apk", but I got error
App not installed.
Did I missed any steps? Why can't I install this app? I thought for a release, the apk should have everything it need to run my app.
Try this and make sure you have created assets folder :
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 \
&& cd android \
&& ./gradlew clean\
&& ./gradlew assembleDebug
After this you can find your debug apk in
/android/app/build/outputs/apk/debug
Hope it will work .

Not able to run on android, while iOS runs fine

I am pretty new to react-native development, I have a project which run properly with iOS simulator, while on android (Emulator and device) it gives Unexpected token '>' error
Try to change "android" folder name to "android-backup"
And run following in the terminal:
$cd MyProjectFolder
$npm start
$react-native start
this work refresh your android project.
also you can clean gradlew with:
$cd android
$gradlew clean
try this
Open Terminal
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
react-native run-android

Disabling JS Server from running on react-native run-android command

I perform offline bundling of my react-native project using CMD
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/
As bundinling is done offline i dont want JS server to start each time after running the command react-native run-android.
Is there any way out to avoid starting JS server
Internally, react-native run-android starts the packager and run installDebug task on gradlew.
To just run installDebug, on your project root directory run:
cd android && ./gradlew installDebug