将 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
原文由 Stackoverflow 发布,翻译遵循 CC BY-SA 4.0 许可协议
我今天也遇到了这个问题,在网上尝试了很多方法,但都没有奏效。以下是我解决此问题的方法:
我使用 Android Studio 在模拟器中运行该应用程序,它工作正常。使用
npx react-native run-android
运行(失败)后,直接使用 Android Studio 运行也失败,我得到错误INSTALL_FAILED_INSUFFICIENT_STORAGE
。此消息比来自 react-native 的错误消息更有帮助。 Then I assigned a bigger storage to my virtual Android phone by going toDevice Manager
>Device Name
>Edit
>Show Advanced Settings
>Internal Storage
.擦除虚拟设备的数据。然后使用 react-native 方法就可以了。