React-Native run-android on specific device

后端 未结 5 436
时光说笑
时光说笑 2021-02-01 14:13

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

5条回答
  •  梦谈多话
    2021-02-01 14:51

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

    cd android
    ./gradlew assembleDebug # assembleRelease for release builds
    adb install -s  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.

提交回复
热议问题