I just created react native app using react-native init demoone
and started js server using react-native start
then trying to execute the app with react-native run-android
But i am getting the following error in emulator when it is installed.
can't find variable: _d(http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:1
)
Open your react native app's directory, navigate to ios folder, and double-click on . xcworkspace file to open the Xcode. Next, open the Product menu, go to Destination, and select your device. If you don't have an Apple Developer account, you must create one to be able to run your project on an iOS device.
I faced the same problem, while trying to set up the react-native env in Win10 and attempting to run Sample Project.
After hours of banging my head and scrolling through site found the solution in here!
The problem is, when you run react-native run-android
from the project root folder, it automatically starts a default instance of node-js packager server at the port 8081. For some reason it doesn't let the hot/live/ or even manual reloading work & throws the same non-descriptive error.
Solution is to stop all running instances of the app & to run:
yarn start
// or
npm start
from the root folder to create your own bundler server manually. Prefer npm
or yarn
over react-native start
(Worked for me)
And then execute
react-native run-android
using another cmd window to run the application on the emulator.
So the idea is to create a separate bundler everytime to run the application.
Works like a Charm!
You need run this command to fix it:
adb reverse tcp:8081 tcp:8081
This sets up a reverse proxy between your emulator/device to your port 8081
. Just make sure your emulator and react native bundler(react-native start) are running before you run this command.
Another thing I came across specific to android emulator, set your debug server host to localhost:8081
from Dev settings in your app, otherwise it doesn't connects to remote debugger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With