I am using such command to generate an APK:
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
Is it possible to edit this command to generate release APK?
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 assembleRelease
./gradlew assembleRelease assembles all release builds (and generates release apk)
Your release build should be available under the following directory: [projectRoot]/android/app/build/outputs/apk/release/
mkdir -p android/app/src/main/assets
&& rm -rf android/app/build
&& 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 assembleRelease && cd ../
I hope this will work for you…
ORG_GRADLE_PROJECT_bundleInArRelease=true npx react-native run-android --variant Release
then you will find the APK inside
./android/app/build/apk/release/
I hope it helps you
Related
I am trying to generate a new apk and I get a very old apk when I run
./gradlew assembleRelease
I am using react native above 0.63.
I tried to remove the build folder and remove caches and it still produces the old apk.
so my question is why does it produce the old apk? and how to get the new apk?
Delete files inside directory android/app/src/main/assets.
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
$ react-native run-android
try with:
rm -rf android/app/build
rm -rf android/build
cd android
./gradlew clean
cd ..
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 assembleRelease
this should clean the build folder and create a new index.android.bundle with all the updates
Try this:
cd android
./gradlew clean
./gradlew assembleRelease
cd ..
Hi I'm new to react native. I have created react native application and for testing I have get the debug apk as output. But once I installed on debug APK on real device some Images are not showing.. Anything wrong I have done ?
I think you haven't bundle your assets before generating debug apk
Try this code in your terminal for bundle all the assets and get debug apk as output
mkdir -p android/app/src/main/assets && rm -rf android/app/build && 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 assembleDebug
I am creating android release build from my react-native app. Everytime it gives me msg app:processReleaseResources FAILED in console.
I have tried
rm -rf android/app/src/main/res/drawable-*
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/build/intermediates/res/merged/release/
cd android && ./gradlew assembleRelease
but got no luck. I don't know what I am doing wrong or missing.
I expect release build created successfully but it is giving me app:processReleaseResources FAILED everytime.
I want to build unsigned apk or debug apk. My application is successfully running on localhost. I have tried different methods. But it shows the error. I have got the answer from Here . when applying the command
react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
It showing the error is
Cannot find entry file index.android.js in any of the roots: ["D:\\workspace\\reactjs\\native\\myapp5"]
Then i have change index.android.js to App.js
Then it will showing the error is
ENOENT: no such file or directory, open 'D:\workspace\reactjs\native\myapp5\android\app\build\intermediates\assets\debug\index.android.bundle'
How to solve this problem? Please help me.
My react native versions are react-native-cli: 2.0.1 , react-native: 0.52.0 . Screenshot of my root folder i have posted.
when i run gradlew assembleDebug in android folder it showing the error.
In your root project directory
Make sure if you have already directory android/app/src/main/assets/ if not there create directory after that create new file and save as index.android.bundle and put your file in like this android/app/src/main/assets/index.android.bundle
After run this in cmd
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 assembleDebug
then you can get apk app/build/outputs/apk/debug/app-debug.apk
The problem here is that you do not seem to have the entry file you have specified for react native bundle:
index.android.js
Replace it with your project's entry file index.js or app.js according to your project structure.
Update:
react-native bundle --dev false --platform android --entry-file <your-entry-file> --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
Create debug build:
cd android && ./gradlew assembleDebug
Your apk will be at android/app/build/outputs/apk
In the root folder of your project, run the following command:
For RN Old Version:
mkdir -p android/app/src/main/assets && rm -rf android/app/build &&
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 clean assembleDebug && cd ../
For RN New Version:
mkdir -p android/app/src/main/assets && rm -rf android/app/build &&
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 assembleDebug && cd ../
The apk is generated in following folder:
app/build/outputs/apk/debug/app-debug.apk
And if you want to run the apk on simulator. Run the following command:
react-native run-android --variant=debug
This will work..
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 assembleDebug
I have used following command to run but index.android.bundle not getting.
react-native run-android
react-native start
http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false
This is not giving me the package bundle js what to do. and It's been a couple of days i stock in this problem i could not get help.
Below is the screencast of my code:
Thanks in Advance!
Your screenshot starting the server for react native debug.
The app in the debug mode will point to this server js then you can change your code for debug easily.
If you want to package the bundle file you can use these commands:
Android:
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/
IOS:
react-native bundle --platform ios --dev false --assets-dest ./ios --entry-file index.ios.js --bundle-output ios/main.jsbundle
Got Solution For me:
Go to your project directory and check if this folder exists android/app/src/main/assets
i) If it exists then delete two files viz index.android.bundle and index.android.bundle.meta
ii) If the folder assets doesn’t exist then create the assets directory there.
From your root project directory do
cd android
./gradlew clean
Finally, navigate back to the root directory and check
i) If there is only one file i.e. index.js then run following command
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
NOTE: That is one single command.
ii) If there are two files i.e index.android.js and index.ios.js then run this:
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
This is a single command too!
Now run react-native run-android
Found Solution from this url, Click here to Check
I have just found why my react-native application is not building bundle js because of watchman and after uninstall previous watchman and installing new watchman.It working correctly thanks. Using Following Code.
$ git clone https://github.com/facebook/watchman.git
$ cd watchman/
$ git checkout v4.7.0
$ sudo apt-get install -y autoconf automake build-essential python-dev
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
$ watchman --version
$ echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches && echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_queued_events && echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_instances && watchman shutdown-server