解决android手机不弹出授权,导致Android studio连接不上真机

2,973 阅读1分钟
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
> Task :app:installDebug FAILED
Skipping device 'P4M7N15311003088' (P4M7N15311003088): Device is OFFLINE.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
60 actionable tasks: 1 executed, 59 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details. 
  • 在切换模拟器和真机测试时常常真机不弹出授权,运行adb devices出现unauthorized
PS D:\Program Files\Nox\bin> adb devices
List of devices attached
P4M7N15311003088        unauthorized

解决方案

  • cmd 运行adb kill-server
  • 在运行adb start-server 此时就会弹出授权
  • 最后在adb devices
PS D:\Program Files\Nox\bin> adb devices
List of devices attached
P4M7N15311003088        device