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
Related
i have a react native app and im able to run it when i connect my phone and run the command react-native run-android but when i go to github and download the apk file from android/app/build/outputs/apk/debug/app-debug.apk and install the app i get this
i have android:usesCleartextTraffic="true" but i dont know what else to do
use below commands to create debug apk
1.
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
cd android && ./gradlew assembleDebug
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.
Android Studio is generating very old apk for react-native project like 3 months old. But running perfectly in emulator while running this command "react-native run-android"
Process -
* Open file location
* Build => Build Bundles => Build APK
Tried re-installing android studio but still getting old APK
In the old react-native version, when we generate the android APK, sometimes the bundle is old, we have to generate it by ourself.
In the react-native 0.61, I find the problem is dismissed.
In the old version, firstly you should add the following script to the package.json
"scripts":{
...
"bundle-android": "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",
...
}
the when you generate the apk , you firstly run the follwing script in the termail to generate the new bundle
npm run bundle-android
when the bundle outputs successfully, then go into the android directory and assemble the APK
cd android
./gradlew assembleRelease
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/
If you get an error of duplicate resources than go to res folder and delete the drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi folder only and try to rebuild the project. It will work.
It is because, you have old index.android.bundle file. Follow these steps to update this file and create a new 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
curl "http://localhost:8081/index.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
cd android && ./gradlew clean 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