Reputation: 413
I am building React Native app.
It is working well when I launch the app in terminal on Mac using "react-native run-android".
But when I got the apk file and installed it on another android device manually, it does not work.
It looks like this.
Upvotes: 29
Views: 129755
Reputation: 743
Get a list of all the devices:
adb devices
Then set the which device to run on:
adb -s <device name> reverse tcp:8081 tcp:8081
Then deploy the app:
react-native run-android
Upvotes: 4
Reputation: 61
Please find the below steps to run react-native code on a physical mobile device:-
6. wait for a minute app will install and reflect the changes.
Upvotes: 3
Reputation: 9885
If you are connected via cable, do the following:
On Windows open Android SDK Manger > Platform Tools
Type:
$ adb devices
This will show you the devices and simulator/virtual-devices that you have on you computer.
Type:
$ adb reverse tcp:8081 tcp:8081
Type:
$ npm run android
The app should appear on your device
Upvotes: 49
Reputation: 4566
If you've upgraded your version of react-native since generating your android project files, you might want to regenerate those now. I think you can use react-native upgrade
.
Upvotes: 1
Reputation: 620
Looks like the source code in your APK is looking for the package server.
Read this on how to build APKs for react-native: React-Native - Generating Signed APK
If your devices is connected via cable:
- If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device
Otherwise, you can still do this via Wifi by following the last point in the error:
- If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server -e.g. 10.0.1.1:8081
Upvotes: 23