首页 > 解决方案 > React-Native-CLI & Android : 启动应用失败。确保您已设置 Android 开发环境

问题描述

我无法在我的 android 设备中运行现有的 react-native-cli 应用程序。iOS模拟器发生了类似的事情,但我设法解决了它。所以现在我只能运行 iOS 而不是 android。请查看错误消息并告诉我该怎么做。

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: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.banana.apple signatures do not match previously installed version; ignoring!

* 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 9s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Unable to install C:\Users\Admin\Desktop\Materials\Source Code\PunreachAPP\android\app\build\outputs\apk\debug\app-debug.apk

标签: react-nativeandroid-emulatorreact-native-androidreact-native-cli

解决方案


您之前必须使用不同的版本代码和版本名称安装该应用程序(可能来自 Play 商店)。因此,为了构建和运行应用程序,您需要卸载之前安装的带有包 id 的应用程序

com.banana.apple

您可以通过 2 种方式执行此操作:

  1. 像从您的设备上一样手动卸载任何其他应用程序
  2. 通过 USB ( source )连接手机时运行以下命令。

adb 卸载“com.banana.apple”


推荐阅读