简体   繁体   English

react-native:app:installDebug 失败

[英]react-native :app:installDebug FAILED

Install APK debug to my device failed.将 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

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/android-setup.html确保您有 Android 模拟器正在运行或已连接设备并已设置您的 Android 开发环境:https://facebook.github.io/react-native/docs/android-setup.html

I look at my devices我看看我的设备

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

Since you are using Mi phone which has MIUI由于您使用的是带有 MIUI 的小米手机

try this试试这个

go to Developer options, scroll down to find 'Turn on MIUI optimization' & disable it.转到开发人员选项,向下滚动以找到“打开 MIUI 优化”并禁用它。 Your Phone will be rebooted您的手机将重新启动

check now现在检查


If you are using any other android phone, which has a custom skin/UI on top of android OS, then try disabling the optimization provided by that UI and check.如果您使用的是在 android OS 之上具有自定义皮肤/UI 的任何其他 android 手机,请尝试禁用该 UI 提供的优化并检查。
(usually you can find that in 'Developer options') (通常您可以在“开发人员选项”中找到)

In my case, I have set up a new app but I was getting errors, tried many possible ways and answers from github and stackoverflow.就我而言,我已经设置了一个新应用程序,但出现错误,尝试了许多可能的方法和来自 github 和 stackoverflow 的答案。 nothing worked没有任何效果

error错误在此处输入图片说明 The solution for me was .. check if you already have an app with the same name is installed in android..我的解决方案是..检查您是否已经在android中安装了同名的应用程序..

Delete old apps and run react-native run-android

Worked for me.为我工作。

on my android device, the problem was about the previous build versions of the application that I had installed on my phone before.在我的 android 设备上,问题出在我之前在手机上安装的应用程序的先前构建版本。 the following steps solved my problem:以下步骤解决了我的问题:

  1. removing any previous build of the application, including debugging version and signed apk version删除应用程序的任何先前版本,包括调试版本和签名的 apk 版本

  2. on windows: on the root directory of your project, run :在 Windows 上:在项目的根目录中,运行:

    cd android

    .\\gradlew clean

    cd ..

    npm cache clean --force

    on MacOS: on the root directory of your project, run :在 MacOS 上:在项目的根目录中,运行:

    cd android

    .\\gradlew clean

    cd ..

  3. reboot your android device重启你的安卓设备

I had this issue.我有这个问题。 Mine worked on the emulator well but it didn't work on the device and the error was我的在模拟器上运行良好,但在设备上不起作用,错误是

app:installDebug FAILED.应用程序:安装调试失败。

If you have a different app with the same name (or package name) on the device: Rename the app or delete it from your device.如果设备上有同名(或包名称)的其他应用程序:重命名应用程序或将其从设备中删除。

This works for me这对我有用

  1. Uninstall the app from your phone从您的手机卸载该应用程序
  2. cd android光盘安卓
  3. gradlew clean渐变干净
  4. cd ..光盘..
  5. react-native run-android react-native run-android

I got the same problem and did some research.我遇到了同样的问题并做了一些研究。 This problem happens a lot on Chinese android phones.这个问题在中国安卓手机上经常发生。

It was solved by change the gradle version to 1.2.3 in file android/build.gradle line 8它是通过在文件 android/build.gradle 第 8 行中将 gradle 版本更改为 1.2.3 解决的

classpath 'com.android.tools.build:gradle:1.2.3'
  1. Go to android/build.gradle , change转到android/build.gradle ,更改

    classpath 'com.android.tools.build:gradle:2.2.3' to classpath 'com.android.tools.build:gradle:2.2.3'

    classpath 'com.android.tools.build:gradle:1.2.3'

  2. Then, go to android/gradle/wrapper/gradle-wrapper.properties , change distributionURL to https://services.gradle.org/distributions/gradle-2.2-all.zip然后,转到android/gradle/wrapper/gradle-wrapper.properties ,将 distributionURL 更改为https://services.gradle.org/distributions/gradle-2.2-all.zip

  3. Run again.再跑。

I solved this adding more memory to the device, I did that in this way:我解决了这个向设备添加更多 memory 的问题,我是这样做的:

  1. Open Android studio打开Android工作室
  2. click More Actions and open Virtual Device Manager单击更多操作并打开虚拟设备管理器
  3. Click the pencil icon单击铅笔图标
  4. Click "Show advance settings"点击“显示高级设置”
  5. Increase memory in "Internal Storage option"在“内部存储选项”中增加memory
  6. Click "Finish"点击“完成”

In my case (with React Native), my Android phone was unrecognized by my PC where I was running the server, which can be seen by the message:在我的情况下(使用 React Native),我运行服务器的 PC 无法识别我的 Android 手机,可以通过以下消息看到:

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.

If that is the case, as highlighted in ADB Android Device Unauthorized , make sure that in Developer Options on your phone USB Debugging is set to true, and enter the following commands in terminal or cmd to restart the Android server.如果是这种情况,如ADB Android Device Unauthorized 中突出显示的那样,请确保在手机上的开发人员选项中将USB 调试设置为 true,并在终端或 cmd 中输入以下命令以重新启动 Android 服务器。

adb kill-server
adb start-server

And adb devices should list your phone as device instead of unauthorized并且adb devices应该将您的手机列为device而不是unauthorized

If none of the above solutions works then try the following steps to cold boot the emulator如果上述解决方案均无效,请尝试以下步骤冷启动模拟器

open AVD manager -> Edit device -> Show Advanced Settings -> Boot option -> select Cold Boot instead of Quick boot.打开 AVD 管理器 -> 编辑设备 -> 显示高级设置 -> 启动选项 -> 选择冷启动而不是快速启动。

I also got troubles with app using gradle 2.14, though with gradle 4 it's ok.我也遇到了使用 gradle 2.14 的应用程序的问题,但使用 gradle 4 没关系。 By using --deviceID flag app instals without any issue.通过使用 --deviceID 标志应用程序安装没有任何问题。

react-native run-android --deviceId=mydeviceid

In my case, I had the app downloaded from PlayStore and I was trying to debug the APK with the same name.就我而言,我从 PlayStore 下载了该应用程序,并尝试调试具有相同名称的 APK。 I just uninstalled the app and debugged successfully.我刚刚卸载了应用程序并调试成功。

我遇到了这个问题,我从我的 android 设备/模拟器中删除了 apk 文件,然后运行 ​​react-native run-android 并成功运行。

就我而言,我手动删除了app-debug.apk文件并再次运行它。

  1. Delete the app from the device.从设备中删除应用程序。
  2. Edit the file (YourAppName -> android -> app -> build.gradle) enter the line below on the defaultConfig field编辑文件 (YourAppName -> android -> app -> build.gradle) 在 defaultConfig 字段中输入以下行

multiDexEnabled true multiDexEnabled true

defaultConfig {
    multiDexEnabled true //this is the line you need to enter
    applicationId "xxxxxx"
    minSdkVersion xxxxx
    targetSdkVersion xxxxx
    versionCode xx
    versionName "xx"
}
  1. rebuild the app重建应用程序

Android 设备内存不足,可能就是这个原因。

在 MIUI 上,默认情况下,内部开发人员选项“通过 USB 安装”被禁用。启用它,然后它允许通过 USB 安装应用程序。

打开avd manager单击铅笔图标旁边的箭头并擦除数据对我有用...

Just go to the Developer option in your phone and disable and again enable usb debugging.只需转到手机中的开发人员选项并禁用并再次启用 USB 调试。 It will work.它会起作用。

对我来说,重启手机就成功了。

Step 1: Close Android Emulator.第 1 步:关闭 Android 模拟器。

Step 2: Open Android Virtual Device Manager and wipe data by the following image:第 2 步:打开 Android 虚拟设备管理器并通过下图擦除数据: 在此处输入图片说明

Step 3: Open your terminal and type第 3 步:打开您的终端并输入

cd android
.\gradlew clean
cd ..
npm cache clean --force

Step 4: In terminal, run:第 4 步:在终端中,运行:

yarn run android

Note: If you are using yarn, just run:注意:如果您使用的是纱线,只需运行:

yarn cache clean

Previously, I had installed npm and then installed yarn , and that is when I started to have problems compiling, even when creating new projects with react-native init .以前,我安装了 npm ,然后安装了yarn ,那是我开始在编译时遇到问题的时候,即使在使用 react-native init 创建新项目时也是如此。 Uninstalling yarn , I was able to create and compile.卸载yarn ,我能够创建和编译。

就我而言,我的设备上没有足够的空间来安装该应用程序,因此我清理了一些空间并再次尝试

As you add more modules to Android, there is an incredible demand placed on the Android build system, and the default memory settings will not work.当您向 Android 添加更多模块时,对 Android 构建系统的需求令人难以置信,默认内存设置将不起作用。 To avoid OutOfMemory errors during Android builds, you should uncomment the alternate Gradle memory setting present in /android/gradle.properties :为避免 Android 构建期间出现OutOfMemory错误,您应该取消注释/android/gradle.properties的备用 Gradle 内存设置:

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

In my case, It is problem of permissions or we can say that setting problem present inside developer options.就我而言,这是权限问题,或者我们可以说开发人员选项中存在设置问题。 I am using MI Note 10.To avoid this issue,permit some setting such as common one developer option and USB debugging as well as Install via USB,USB debugging(Security settings), Verify apps over USB.我正在使用 MI Note 10。为避免此问题,请允许一些设置,例如常见的开发人员选项和 USB 调试以及通过 USB 安装、USB 调试(安全设置)、通过 USB 验证应用程序。

I solved this issue by deleting the current device and just creating a new one.我通过删除当前设备并创建一个新设备解决了这个问题。

Install APK debug to my device failed.将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

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/android-setup.html确保已运行Android模拟器或已连接设备,并已设置Android开发环境:https ://facebook.github.io/react-native/docs/android-setup.html

I look at my devices我看着我的设备

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

I had the same issue with wrong AVD settings.我在错误的 AVD 设置中遇到了同样的问题。 Probably, "Target Android 6.0" was wrong choice.可能,“Target Android 6.0”是错误的选择。

Next settings were changed to fix ":app:installDebug FAILED" issue: System Image: Marshmallow , API 23, ABI x86, Target Google API.下一个设置已更改以修复“:app:installDebug FAILED”问题:系统映像:棉花糖、API 23、ABI x86、目标 Google API。

see the detail information about this here: RN Android Setup在此处查看有关此的详细信息: RN Android Setup

只需锁定和解锁android就解决了我的问题

adb reverse tcp:8081 tcp:8081

I got the same error but the issue was I did on the USB Debugging after unable this is working for me.我遇到了同样的错误,但问题是我在USB Debugging上做的,这对我不起作用。

在此处输入图片说明

For me I solved it by uninstalling the already existing app from my phone first (which I was working on the day before the day I got this issue) then building again, it happened to me a few times I think that's how I solved it always.对我来说,我通过先从我的手机上卸载已经存在的应用程序来解决它(我在遇到这个问题的前一天正在工作)然后重新构建,它发生在我身上几次我认为我总是这样解决它.

I also faced this issue today, tried many methods online but none of them worked.我今天也遇到这个问题,网上试了很多方法都没用。 Here is how I solved this issue:这是我解决这个问题的方法:

I used Android Studio to run the app in emulator, it worked.我使用 Android Studio 在模拟器中运行该应用程序,它工作正常。 After using npx react-native run-android to run (which failed), running using Android Studio directly also failed, and I got the error INSTALL_FAILED_INSUFFICIENT_STORAGE .使用npx react-native run-android运行(失败)后,直接使用 Android Studio 运行也失败,报错INSTALL_FAILED_INSUFFICIENT_STORAGE This message was much more helpful than the error message from react-native. Then I assigned a bigger storage to my virtual Android phone by going to Device Manager > Device Name > Edit > Show Advanced Settings > Internal Storage .此消息比来自 react-native 的错误消息更有帮助。然后我通过转到Device Manager > Device Name > Edit > Show Advanced Settings > Internal Storage ,为我的虚拟 Android 电话分配了更大的存储空间。 Wipe virtual device's data.擦除虚拟设备的数据。 Then using the react-native method can work.然后使用react-native方法就可以了。

1. Increase virtual device's internal storage in Android Studio
2. Wipe virtual device's data
3. Run

I got the same issue, restarting emulator solved it. 我遇到了同样的问题,重新启动模拟器解决了它。 This happens as device appears to be offline. 这是因为设备似乎处于脱机状态。

In my case, I uninstall the app and do the whole rebuild sequence again. 在我的情况下,我卸载应用程序并再次执行整个重建序列。 Hope this help! 希望这有帮助!

我的解决方案是删除android/app/build文件夹

cd android and run ./gradlew clean cd android 并运行./gradlew clean

After that create a new virtual device that should work之后创建一个应该可以工作的新虚拟设备

从cmd安装APK调试你的emülator已经打开并再次尝试完成。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 react-native run-android:app:installDebug 失败 - react-native run-android :app:installDebug failed React-Native 项目卡在:app:installDebug - React-Native project stuck on :app:installDebug React Native-任务':app:installDebug'的执行失败 - React Native - Execution failed for task ':app:installDebug' React Native:任务:应用程序:安装调试失败 - React Native: Task :app:installDebug FAILED React-Native(Android)错误:任务:app:installDebug FAILED(macOs Big Sur) - React-Native (Android) error : Task :app:installDebug FAILED (macOs Big Sur) 任务':app:installDebug'的执行失败反应本机应用程序 - Execution failed for task ':app:installDebug' react native app 当为运行模拟器adb android studio运行react-native run-android时,显示错误app:installDebug FAILED - When run react-native run-android for run emulator adb android studio, show error app:installDebug FAILED react-native run-android 命令失败,但 gradlew installDebug 工作 - react-native run-android command failed, but gradlew installDebug work 尝试在 MI MAX 2 android 设备上运行本机应用程序时应用程序安装调试任务期间出现安全异常 - SecurityException during app:installDebug Task while attempting to run react-native app on MI MAX 2 android device “命令失败:./gradlew installDebug”问题(react-native run-android) - "Command failed: ./gradlew installDebug" Problem (react-native run-android)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM