Can't generate release APK of new coded in React Native - android

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

Related

metro error when running react native app from apk file

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

React Native - Build successful but no APK output

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/

How to generate Android app bundle in React Native?

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.

React Native Android runs in dev but not with release [duplicate]

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

React Native App Crashes on "--variant=release" command : Signed APK

I have been trying to build the Signed APK of an application having simple navigation drawer. I have created the keystore as followed the official react docs. But finally once oi created the bundle i am trying to run "react-native run-android --variant=release", it gives a successful build but the app crashes once i open the nav drawer swipe right. But the app works totally fine running with the development server. I even tried $ cd android && ./gradlew bundleRelease , even then the application crashes at the same point. Can even suggest me how could i fix this , will this be a setup issue ?
Try to bundle all assets but before that delete files inside directory
android/app/src/main/assets
and then 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
and then try to continue with your steps.

Categories

Resources