简体   繁体   English

Android Studio 卡在“安装 APK”上

[英]Android Studio Stuck on “Installing APK”

Android Studio no longer seems to be detecting when an app has installed on a target device and opened. Android Studio 似乎不再检测应用程序何时安装在目标设备上并打开。 It gets stuck on "Installing APK" and the progress bar is empty.它卡在“正在安装 APK”上,进度条为空。 There are no errors, the apk successfully installs and opens, it's just the IDE is still showing "Installing APK" and it does not automatically connect the debugger.没有错误,apk成功安装并打开,只是IDE仍然显示“安装APK”并且没有自动连接调试器。 I can manually connect the debugger using the "Attach debugger to Android process button", but this is not ideal.我可以使用“将调试器附加到 Android 进程按钮”手动连接调试器,但这并不理想。

Can anyone offer any suggestions for what's up and how to resolve it?任何人都可以就发生了什么以及如何解决它提供任何建议吗?

It turns out the problem wasn't with Android Studio, but with the device I was using for testing.事实证明,问题不在于 Android Studio,而在于我用于测试的设备。 I tried a different device and it behaved normally, progressing beyond "Installing APK" and stopping on breakpoints.我尝试了一个不同的设备,它运行正常,超越了“安装 APK”并在断点处停止。

Somehow the "wait for debugger" setting in developer options on the problem device had switched to off.不知何故,问题设备上开发人员选项中的“等待调试器”设置已关闭。 I switched this back on and now this device is behaving normally.我重新打开它,现在这个设备运行正常。

-Note that I had to choose an arbitrary debug app for the setting to become active. - 请注意,我必须选择一个任意调试应用程序才能使设置变为活动状态。 Once I'd set it on, I deselected the debug app and the setting remained on, as I left it.一旦我设置了它,我就取消了调试应用程序的选择,并且在我离开它时设置保持打开状态。 This was a HUAWEI P8 running android 6.0 API Level 23.这是运行 android 6.0 API Level 23 的 HUAWEI P8。

Recently, I was facing the same issue when I have updated My Device (MI A1) OS from Android Oreo(8.0) to Android Pie(9.0) ,最近,当我将我的设备 (MI A1) 操作系统从 Android Oreo(8.0) 更新到 Android Pie(9.0)时,我遇到了同样的问题,

Solution: Go to the Settings > Developer options > Now click on > Revoke USB debugging authorisations .解决方案:转到Settings > Developer options > Now click on > Revoke USB debugging authorizations

It will disable/remove developer options from your device, Now restart your device once and then you just need to re-enable your developer options and that all you need to do, Enjoy Developing on Pie.它将从您的设备中禁用/删除开发人员选项,现在重新启动您的设备一次,然后您只需要重新启用您的开发人员选项以及您需要做的所有事情,享受在 Pie 上开发。

Hope this will help you as well.. :)希望这也能帮助你.. :)

I found a solution that works for me.我找到了一个适合我的解决方案。 In Developer Options turn off "Monitor apps installed by ADB".在开发者选项中关闭“监控 ADB 安装的应用程序”。

截图

在我的 HTC One 上,我在“设置”->“开发人员选项”中取消选中“通过 USB 验证应用程序”。

只需重新启动您的手机(:更新 android 版本后会发生这种情况。

I had this same problem.我有同样的问题。 I solved it by revoking USB Debugging Authorizations and then re-enabling USB Debugging on my chosen device(s).我通过撤销 USB 调试授权,然后在我选择的设备上重新启用 USB 调试来解决它。

Edit: Cleaning my project also helped with solving this problem.编辑:清理我的项目也有助于解决这个问题。

for me it was something magic I solve it by removing the USB from the Laptop and from mobile too(type-c cable) and对我来说,这是一件神奇的事情,我通过从笔记本电脑和移动设备上移除 USB 来解决它(type-c 电缆)和

turning off the debugging mode and again turn it on关闭调试模式并再次打开它

and then I connect it back to my Laptop and selected the same FILE TRANSFER MODE then run the app and it get installed to my device and work as expected Hope you will find Useful to然后我将它连接回我的笔记本电脑并选择相同的文件传输模式然后运行该应用程序并将其安装到我的设备并按预期工作希望你会发现有用

I have this problem recently on my Pixel 2 testing device, latest factory image with Android Studio 3.4, on windows 10.我最近在 Windows 10 上的 Pixel 2 测试设备上遇到了这个问题,Android Studio 3.4 的最新出厂映像。

I have tried all methods mentioned but none of them work.我已经尝试了所有提到的方法,但没有一个有效。 It cost me more than 6 hours to figure it out.我花了6个多小时才弄明白。

My problem is the USB driver, I am not using the "perfect" USB driver.我的问题是 USB 驱动程序,我没有使用“完美”的 USB 驱动程序。 My driver works in most scenarios and commands but not in every scenario.我的驱动程序适用于大多数场景和命令,但并非适用于所有场景。

You do not need Android Studio to dig into this problem, just using adb.您不需要 Android Studio 来深入研究这个问题,只需使用 adb。

Please try if you can install apk from adb using following command:请尝试是否可以使用以下命令从 adb 安装 apk:

adb install xxxx.apk

If it stuck at "performing streamed install" but never finish, this is the problem.如果它停留在“执行流式安装”但从未完成,这就是问题所在。

Please try push a big file(more than 5MB) to your device:请尝试将大文件(超过 5MB)推送到您的设备:

adb push xxxx.apk /storage/emulated/0

In my testing, it stuck at 13%, 16%, etc, but never go on.在我的测试中,它停留在 13%、16% 等,但从未继续。 It seems cannot transfer large files.好像不能传输大文件。 This is why the installation is pending in my case.这就是安装在我的情况下未决的原因。

I update the driver to another one, and the problem is fixed.我将驱动程序更新为另一个驱动程序,问题已解决。 Hope it can solve your problem, too.希望它也能解决你的问题。

I had the exact same problem.我遇到了完全相同的问题。

what's more, i can not adb shell and adb push files.更重要的是,我不能 adb shell 和 adb push 文件。

I am running an Ubuntu 18.04 VM and test on xiaomi phone 8,9.我正在运行 Ubuntu 18.04 VM 并在小米手机 8,9 上进行测试。 The problem for me was the USB Compatibility setting for the VM was set to 2.0, it needs to be at least 3.0.我的问题是 VM 的 USB 兼容性设置设置为 2.0,它至少需要为 3.0。 To change the setting power down the VM and choose the "Edit virtual machine settings" in the VMPlayer startup menu.要更改设置,请关闭 VM 并在 VMPlayer 启动菜单中选择“编辑虚拟机设置”。 Then select the "USB Controller" device and change "USB Compatibility" to USB 3.0.然后选择“USB 控制器”设备并将“USB 兼容性”更改为 USB 3.0。 Hope this can help u!希望这可以帮助你!

It doesn't hurt to verify your USB port.验证您的 USB 端口并没有什么坏处。 In my case it was the faulty USB port which I had to switch to the mobo's one instead of the case port.就我而言,是 USB 端口有问题,我不得不切换到主板的 USB 端口而不是机箱端口。

重新启动 Android Studio 对我有用

我尝试重新启动我的手机,它奏效了。

When attach my mobile to my PC, the follow menu is showed.将我的手机连接到我的 PC 时,会显示以下菜单。 I Clicke on it.我点击它。 在此处输入图片说明

In the next section, I had changed from "USB connection" to "Transfer files"在下一节中,我已从“USB 连接”更改为“传输文件”

从电缆模式到传输模式

After that adb install works for me.之后 adb install 对我有用。

In my case, Second Space was created but not switched on.就我而言,第二空间已创建但未打开。 I had to delete the second space and everything worked just fine.我不得不删除第二个空间,一切正常。

My settings are:我的设置是:

  • Usb debugging -> ON USB调试->开启
  • Install via Usb -> ON通过 USB 安装 -> ON
  • Verify over USB -> ON通过 USB 验证 -> 开启
  • Wait for debugger -> ON等待调试器 -> ON

Device: Redmi Note 5 Pro设备:红米 Note 5 Pro

I had this issue with an emulator on Linux.我在 Linux 上的模拟器上遇到了这个问题。 After trying pretty much every solution and suggestion on this page, what made it work for me was turning off Instant Run.在尝试了此页面上的几乎所有解决方案和建议之后,它对我有用的是关闭 Instant Run。

In my case i did not make sure that my android studio DSK manager was up to date with the android version that my device was operating on.就我而言,我没有确保我的 android studio DSK 管理器与我的设备运行的 android 版本保持同步。 So when running flutter doctor all seemed well, and i had the latest android version and all on android studio, but as mentioned it was not matching the version for my device i had connected.因此,当运行 flutter doctor 时,一切似乎都很好,而且我拥有最新的 android 版本,并且都在 android studio 上,但如前所述,它与我连接的设备版本不匹配。

Once i added the correct android version (in my case android 6.0) with SDK manager using android studio, it did not get stuck at installing apk.一旦我使用 android studio 添加了带有 SDK 管理器的正确 android 版本(在我的情况下为 android 6.0),它就不会在安装 apk 时卡住了。

My case was similar but for Android Version 10 required having the Verify bytecode of debuggable apps to off.我的情况类似,但对于 Android 版本 10,需要关闭可调试应用程序的验证字节码。

Final settings were:最终设置是:

  • USB debugging -> ON USB调试->开启
  • Wait for debugger -> ON等待调试器 -> ON
  • Verify apps over USB -> ON通过 USB 验证应用程序 -> 开启
  • Verify bytecode of debuggable apps -> OFF验证可调试应用程序的字节码 -> OFF

Device: Pixel XL设备:Pixel XL

For me, the top answer "wait for debugger" was completely greyed out.对我来说,最重要的答案“等待调试器”完全变灰了。

What worked for me was to look inside "Apps" and I noticed the app was uninstalled, but only for my current user.对我有用的是查看“应用程序”内部,我注意到该应用程序已被卸载,但仅适用于我当前的用户。 Clicking uninstall for all users unblocked the installation via Android Studio again.单击所有用户的卸载再次通过 Android Studio 取消阻止安装。

Check following in your project在您的项目中检查以下内容

  • build-gradle plugin version in project level build.gradle file项目级build.gradle文件中的 build-gradle 插件版本
  • gradle version in gradle-wrapper.properties file gradle-wrapper.properties文件中的 gradle 版本
  • buildToolsVersion构建工具版本

卸载以前安装的应用程序对我有用

Turn off Verify apps over USB and Verify bytecode for debuggable apps (might not be available for all devices) in your Developer settings menu.在开发人员设置菜单中关闭通过 USB 验证应用程序验证可调试应用程序的字节码(可能不适用于所有设备)。 The install time will decrease drastically.安装时间将大大减少。

I'm using Visual Studio Xamarin and the issue was caused by the missing CPU architecture.我正在使用 Visual Studio Xamarin,问题是由缺少 CPU 架构引起的。 After checking them, the APK became installable via adb install ...检查后,APK 可以通过adb install ...

在此处输入图片说明

Just reboot your mobile .只需重新启动您的手机。 If not working try reboot your Android studio and mobile.如果不起作用,请尝试重新启动您的 Android 工作室和手机。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM