react-native run-android
command terminates by leaving a message in android simulator. The message is as follows:
Unable to load script.Make
Starting with Android 9.0 (API level 28), cleartext support is disabled by default.
This is what you need to do to get rid of this problem if you do normal run commands properly
And modify your android manifest file like this.
<application
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true" // add this line with TRUE Value.
android:theme="@style/AppTheme">
The solution that worked for me is the following:
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
possibility of this error is also the wrong path,check once
export ANDROID_HOME=/Users/microrentindia/Library/Android/sdk/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
IMPORTANT - You might have many Virtual devices in your environment. Ensure if you are changing AVD you repeat the setting again.
Incase you are experiencing above error you have to 1st verify what is running on port 8081
Quickest way to find that is using the following command in terminal
netstat -aon | findstr 8081
if that shows you something it means the port is blocked. if possible get that port unblocked.
Otherwise, you would need to change the port. The process to do that has already been mentioned in the comment above by Naveen Kumar
react-native run-android --port=9001
Ensure 9001 is not used either :)
My solution to this is as below:
Start Metro server
$ react-native start
Start Android
$ react-native run-android
If see errors saying "port 8081 already in use", then you can kill that process and rerun
$ react-native start
See React Native Troubleshooting Page .
The error message on the emulator is kind of misleading. In my case, I used a Macbook. I needed to change the permissions on android/gradlew by running $ chmod 755 ./gradlew
, and then the app could be built and deployed to the android emulator.