Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
507 views
in Technique[技术] by (71.8m points)

adb - React-Native run-android on specific device

Is it possible to use the run-android command for one specific device only?

For example, if I have three devices (or emulators) connected and I want to use run-android on only one of them?

Maybe something like adb install -s DEVICE_NUMBER?

Thanks in advance

question from:https://stackoverflow.com/questions/40725219/react-native-run-android-on-specific-device

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Elaborating on @alexander 's answer, you can use the following workflow:

cd android
./gradlew assembleDebug # assembleRelease for release builds
adb install -s <yourdevice> app/build/outputs/apk/yourapk.apk # You can check the identifier for your device with adb devices
adb reverse tcp:8081 tcp:8081 Will forward the phone's 8081 port to the computer's 8081, where the packager listens. If you are deploying over Wi-Fi, have a look at: https://facebook.github.io/react-native/docs/running-on-device-android.html#configure-your-app-to-connect-to-the-local-dev-server-via-wi-fi

In a different screen, run:

npm start # Will run the packager

If you really need this, you might want to wrap the first snippet into a script that you can parametrize with your phone's identifier.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...