react-native run-android
command terminates by leaving a message in android simulator. The message is as follows:
Unable to load script.Make
update this part in metro blacklist
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
By default a tiny JavaScript server called "Metro Server" runs on the port 8081.
You need to make this port available for this Server to start. So,
How to release the port?
http://tenbull.blogspot.com/2019/05/how-to-kill-process-currently-using.html
How to kill the process currently using a port on localhost in windows?
and most importantly, I upgraded my node version from 8.x to 10.x(latest), as suggested by facebook @ https://facebook.github.io/react-native/docs/getting-started
For me this problem started with upgrading react-native. The upgrade was necessary to add 64-bit support.
Before:
--------
Environment:
Node: 10.15.0
npm: 6.9.0
Watchman: 4.9.0
Xcode: Not Found
Android Studio: 3.4 AI-183.6156.11.34.5692245
Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: ~0.55.2 => 0.55.4
react-native-cli: 2.0.1
After:
------
info
React Native Environment Info:
Binaries:
Node: 10.15.0
npm: 6.9.0
Watchman: 4.9.0
SDKs:
Android SDK:
API Levels: 23, 26, 27, 28
Build Tools: 27.0.3, 28.0.3
System Images: android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
react: ^16.8.6 => 16.9.0
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
Also, One important change that I made for the upgrade was in ../android/build/build.gradle
android {
...
defaultConfig {
...
targetSdkVersion 28
...
}
...
}
I had to change the targetSdkVersion from 27 to 28 following warning when I tried to upload the build(.apk) to goole play console. Little did i realise that this was the root cause of the above error for me. Immediatly answers by @tom and @tinmarfrutos made absolute sense.
I solved the problem by adding android:usesCleartextTraffic="true" to my android/app/src/debug/AndroidManifest.xml
This worked for me after trying several ways.
In the file node_modules\metro-config\src\defaults\blacklist.js
Replace :
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
with :
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
hope this helps.
For me this error was caused by an upgrade of react-native
Starting with Android 9.0 (API level 28), cleartext support is disabled by default.
If you check out the upgrade diff you need to create a debug manifest
android/app/src/debug/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
See for more info: https://stackoverflow.com/a/50834600/1713216
https://react-native-community.github.io/upgrade-helper/
I was having the same trouble, the problem for me was that adb was not in the right environment path, the error is telling you metro port, while you're in the adb, ports are killed and restarted.
Note: Or depending where is located adb.exe in your machine
Run android build again
$ react-native run-android
Or
$ react-native start
$ react-native run-android