Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native Android Example does not work

Tags:

react-native

I cloned the repository: https://github.com/facebook/react-native and try to run the UIExplorer example on Android emulator.

./gradlew :Examples:UIExplorer:android:app:installDebug
./packager/packager.sh

I got this error message on the Android emulator:

Unable to download JS Bundle, Did you forget to start the development server or connect your device?

I understand this is somewhat similar to this one: react native android failed to load JS bundle

But here I had to use the command "./packager/packager.sh" to run the example. So the answer above does not apply to this case.

like image 876
JustWonder Avatar asked Sep 18 '26 17:09

JustWonder


1 Answers

In order for the app to be able to download the JS Bundle, the packager has to create and serve the JS bundle, and the emulator has to be able to connect to it.

To verify that the bundle is created and served correctly, try browsing to this page in your web browser. This should connect to the packager and get the bundle as the answer. If the packager received the request, the following request message should appear in the packager console:

<START> request:/Examples/UIExplorer/UIExplorerApp.android.bundle?platform=android

If the packager created the correct bundle, it would return get a huge file that starts with something like "__DEV__ = true;. If these two steps did not work, then there's an issue with the packager and you can report the issue on github.

To verify that the emulator can connect to your packager, when you tap Reload JS you should see the same request message in the packager console as above. If no such message appears, then the emulator can't connect to your machine.

like image 82
Andrei Ovidiu Coman Avatar answered Sep 22 '26 16:09

Andrei Ovidiu Coman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!