React Native using android emulator - react-native

I'am just starting with react native using Android emulator on windows. When I follow the react native getting started tutorial and run the app I see 'unable to load script from assets index.android.bundle' error and fixed it by following these steps as explained here :
(in project directory) mkdir android/app/src/main/assets react-native
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 worked good - App.js renders ok, but I am now unable to see any changes made to the code in the emulator (I have tried running npm-start and react-native run-android but no luck). When I hit reload button in the emulator (RR) I see this error : error
I have also tried resetting cache(react-native start --reset-cache) and no luck.
How could I get my changes refreshed in the app please and fix this error? Thanks :)

Related

App being crashed after adding the react-native-jitsi-meet library

I'm trying to implement the video conference functionality by using the react-native-jitsi-meet library. But app is being crashed without showing any issue.
I have used added the package and implemented the android process for the react version > 0.60 as mentioned in the document(https://github.com/skrafft/react-native-jitsi-meet) unable to find the issue. Haven't added any code in the JS file too.
I have tried react-native-jitsi-meet module not found also but still the issue continues.
As it is specified in documentation we already changed the app.bundle as rename and it is bundling incorrectly so do this changes.
Remove the following file
android/app/src/main/assets/index.android.bundle
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/app.bundle --assets-dest android/app/src/main/res/ && cd android && ./gradlew assembleDebug

react-native run-android dev mode not working

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 :)

app directly crashing rather than displaying red alert

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

React native unable to load scripts automatically appear disappear in android

I am running $react-native run-android. it is working properly, also, I am able to see the changes on android emulator. I have created 3 components and also tested it on android device.
But now, suddenly, it is asking me unable to load script from assets 'index.android.bundle' Also, I have reverted the changes and started but still I am seeing this error.
After serching on internet, I performed,
1. npm start
2. react-native start
3. adb kill-server and adb start-server
but all in vein.
Last, I found and performed below commands,
$ mkdir android/app/src/main/assets
$ 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
I am able to resolve above error with above commands, but now, when I am changing App.js file, it is not getting reflected on emulator. please help.
My steps performed: http://sachin4java.blogspot.in/2017/12/unable-to-load-scripts-from-assets.html
I have tried many things as found on internet, but no one worked.
I removed installed node, NPM and nodejs
I installed it again with : http://sachin4java.blogspot.in/2017/12/react-native-setup-in-ubuntu-16.html
Then I installed in new version in Android studio AVD image named 'Nexus_5X_API_26(AVD)'.
Now, I am able to see the code changes reflecting and red error screen gone.

React native building release isn't reflecting changes that debug does (android)

I made some styling changes to my react native app. Everything looks good in debug so I tried to run the release variant using 'react-native run-android --variant=release' and none of that changes in debug show up. I made sure I wasn't crazy and removed the background image. The release variant didn't change at all. I then tried generating the signed apk and installing it manually. Same thing.
I can't seem to find anything on google. Has anyone had this problem before or have suggestions on what to try? I've combed through all the config files and everything seems right. I know its hard without being able to look at the code but I can't share it since its for internal company use only.
For anyone still struggling with this, updating index.android.bundle usually solves this issue:
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/
1 - Perform adb reverse..check below got to platform-tools in cmd
C:\Users\username\AppData\Local\Android\Sdk\platform-tools --> adb reverse tcp:8081 tcp:8081
2 - Then delete any bundle file if present in 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
3 - run --> react-native run-android --variant=release
or react-native run-android