I created the app by working on the following tasks for the launch of the Android app.
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
After that, I tried to build the app again in development mode (react-native run-android), but the app continues to be built in release mode. How do you build it development mode like before?
react-native run-android
When I do this react-native run-android, Metro Bundle does not run and just build the release app on my device.
I want the Metro Bundle to be turned on and built in development mode when I execute this.
I had the same problem, it was fixed by deleting the line:
import com.facebook.react.BuildConfig;
from the MainApplication.java
Below can clear your thoughts about the metro server and development mode
When you are in development mode and need to debug the application
live by changing the content of the code the you should always do:
react-native run-android, it will always run the metro server and
you have the feature to live reload the application whenever the code
changes. Note: This will work for both the emulator and phones
connected to your pc through cables or by server.
Now, in case you want to build an apk and wanted to test on a real
device which enables you to discard the consoles and for the further
testing the application before making it live then you should always
run the below command
Bundle first all the files, by going inside your project
structure
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/
Now, create a bundle apk by going inside the android folder and run the below command./gradlew assembleDebug
Note : it will create the apk in you build folder inside this
directory project_name\android\app\build\outputs\apk\debug
I hope this helps....Thanks :)
Related
I have made the changes in source code. when running it in debug mode it's working fine changes are. working there. After taking the release build changes are not reflecting in it. why ??? Android build
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
run this command.. may be it's sounds weird but it's work for me
reference : https://stackoverflow.com/a/60015205/6654562
Before Trying to build APK run gradlew clean and clean the gradle folder this will remove all the previous builds. Then try to build the release APK
I am using redux persist and I have previously persisted a list of data, but even after building the app in release, the app is shipped with some previous data that's not cleared out. A fresh build is not there , I have tried the following
react-native run-android --variant=release
cd android && ./gradlew assembleRelease
I have also run this code to bundle, but no use
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/
This is causing an error for me on initial app start up cuz of the old data, and the only way I am able to clear data is clearing app data from device settings
Ok, it seems the issue was from backup process being enabled , this helped https://stackoverflow.com/a/55294158/7266219
Currently I have implemented reactnative to existing native app but its directly crashing when i start it from android studio. windows doesnt turns red as usual.
Process: com.., PID: 15608
java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
The problem that you are facing is that a react native project creates a bundle to load the script for the app which you have not created it so your android app is loading nothing when running the react-native run-android command.
Do this in your project root directory:
1- Run this command mkdir android\app\src\main\assets
2- After this command, run this 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
Step 2 command execution might take time (have patience)
3- then run react-native run-android command
More info at here and here
I have made many changes in my js code, when I run in debug mode I'm able to see all the changes but when I run the app in release mode or generate a release apk, the changes that were made and visible in debug mode are not visible.
What I have already tried?
react-native run-android --variant=release
Deleted the builds folder and android.bundle.js in assets
Run the below command before you run release variant in the project directory.
So command sequence will be first execute
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/
This may take little time to finsh.
Then execute your run command:
react-native run-android --variant=release
I using Sentry to log crashes in my app in production. The sourcemaps are working as expected for iOS app but for Android, I don't the actual file and line number at which the crash happened. The stack trace contains references to index.android.bundle. I use the following command to create the bundle and the map file
react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output index.android.bundle --sourcemap-output index.android.map
I upload the bundle and map files to sentry using command
sentry-cli releases files 1.0.10 upload-sourcemaps --rewrite --url-prefix / ./
I wanted to ask whether anyone has been able to get the sourcemaps to work for Android using Sentry. Are there any other instructions that I need to follow to get the sourcemaps to work for Android app?
It should work if you just call ./gradlew assembleRelease if you are running the latest version of react-native-sentry.
As described here:
https://docs.sentry.io/clients/react-native/#android-specifics