react-native:app:installDebug失败
收藏

将APK调试安装到我的设备失败。

jianglinghuadeMacBook-Pro:hello jianglinghua$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug...
WARNING [Project: :app] Current NDK support is deprecated.  Alternative will be provided in the future.
:app:preBuild UP-TO-DATE
......
:app:assembleDebug UP-TO-DATE
:app:installDebug
Installing APK 'app-debug.apk' on 'MI NOTE LTE - 6.0.1'
Unable to install /Users/jianglinghua/Desktop/hello/android/app/build/outputs/apk/app-debug.apk
com.android.ddmlib.InstallException: Failed to establish session
    at com.android.ddmlib.Device.installPackages(Device.java:894)
    ........
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
:app:installDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 13.945 secs

无法在设备上安装该应用,请阅读上面的错误以获取详细信息。     确保您正在运行Android模拟器或已连接设备,并且     设置您的Android开发环境:     https://facebook.github.io/react-native/docs/android-setup.html

我看着我的设备

jianglinghuadeMacBook-Pro:hello jianglinghua$ adb devices
List of devices attached
98333978    device

最佳答案

由于您正在使用具有MIUI的Mi手机

尝试这个

转到开发人员选项,向下滚动以找到“打开MIUI优化”并禁用它。您的手机将重新启动

现在检查

    公众号
    关注公众号订阅更多技术干货!