java 使用 Android Studio 2.0 启动 Android 应用程序时安装重启补丁时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36680036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:44:54  来源:igfitidea点击:

Error while Installing restart patches when launching android app with Android Studio 2.0

javaandroidandroid-studio-2.0

提问by Victor Oliveira Antonino

Currently I'm using Android Studio 2.0 and installing my APK into my Samsung device (S6). However, when rebuilding my code and running it again I receive the following error:

目前我正在使用 Android Studio 2.0 并将我的 APK 安装到我的三星设备 (S6) 中。但是,当重建我的代码并再次运行它时,我收到以下错误:

Error installing cold swap patches: com.android.tools.fd.client.InstantRunPushFailedException: Error creating folder with: run-as com.appcustomer mkdir -p /data/data/com.appcustomer/files/instant-run/inbox
Error while Installing restart patches

Does anyone have any idea what this issue is?

有谁知道这个问题是什么?

回答by prashant

I think the issue is due to instant run feature of Android Studio 2.0. This might help

我认为这个问题是由于 Android Studio 2.0 的即时运行功能造成的。这可能有帮助

  1. Open the Settings or Preferences dialog.
  2. Navigate to Build, Execution, Deployment > Instant Run.
  3. Uncheck the box next to Restart activity on code changes
  1. 打开设置或首选项对话框。
  2. 导航到构建、执行、部署 > 即时运行。
  3. 取消选中重新启动代码更改活动旁边的框

回答by Dinesh Sachdeva

Me to having the same issue and u can resolve it by uninstalling the app before running the app from android studio

我遇到了同样的问题,你可以通过在从 android studio 运行应用程序之前卸载应用程序来解决它

回答by Kanishka Ganguly

I am having the same issue. My "fix" was to uninstall the app each time before installing it through Android Studio.
What I think is that if your app is running already, Android Studio is unable to rewrite the "updated" build on top of that. So, either you manually stop the app or add thisto Gradle to fix the issue.
I know it's just a workaround and I'd love to get a legitimate fix for this.

我有同样的问题。我的“修复”是每次在通过 Android Studio 安装之前卸载该应用程序。
我认为,如果您的应用程序已经在运行,Android Studio 无法在此基础上重写“更新”构建。所以,要么你手动停止应用程序或添加这个到摇篮来解决该问题。
我知道这只是一种解决方法,我很想为此获得合法的解决方案。

回答by regas

This started happening on my Samsung Tab A as soon as I installed the Marshmallow upgrade. This was painful because Android Studio had to perform a slow recompile of the entire app for every minor code change. Worse, Instrumentation no longer worked, e.g. an NPE would crash the app without showing any messages in the debug window.

安装 Marshmallow 升级后,这开始发生在我的三星 Tab A 上。这很痛苦,因为 Android Studio 必须为每个小的代码更改对整个应用程序执行缓慢的重新编译。更糟糕的是,Instrumentation 不再有效,例如 NPE 会使应用程序崩溃,而不会在调试窗口中显示任何消息。

The problems went away when when I reverted back to Lollipop.

当我回到 Lollipop 时,问题就消失了。

Despite what Samsung support told me, I am able to block the annoying Marshmallow upgrade popups by disabling Software update (com.wssyncmldm and com.sec.android.fotaclient).

尽管三星支持告诉我什么,我还是能够通过禁用软件更新(com.wssyncmldm 和 com.sec.android.fotaclient)来阻止烦人的棉花糖升级弹出窗口。

According to Google "this is a bug on the android software installed on these phones" https://code.google.com/p/android/issues/detail?id=200881. The next device I purchase for app development will not be a Samsung.

据谷歌称“这是这些手机上安装的安卓软件的一个错误” https://code.google.com/p/android/issues/detail?id=200881。我为应用程序开发购买的下一个设备不会是三星。

回答by daisura99

Restarting Android Studio worked for me.

重新启动 Android Studio 对我有用。

I think the error happens when you disconnect the device when it is running your app from Android Studio.

我认为当您从 Android Studio 运行您的应用程序时断开设备连接时会发生错误。

回答by nucleons

Clean the project and in File option of Android Studio press Invalidate Caches/ Restart. Disable Instant Run and do a gradle sync. This worked for me. I am using Mac, I think this will be similar in Windows and Ubuntu.

清理项目并在 Android Studio 的 File 选项中按 Invalidate Caches/ Restart。禁用 Instant Run 并进行 gradle 同步。这对我有用。我使用的是 Mac,我认为这在 Windows 和 Ubuntu 中会类似。

回答by Ispas Claudiu

I updated Android Studio to 2.2.3 and Gradle to 2.14.1 and it worked.

我将 Android Studio 更新到 2.2.3,将 Gradle 更新到 2.14.1 并且成功了。

回答by sadi09

This is session related issue. Restart studio and avoid pulling cable during instant run for future repeat of this problem.

这是与会话相关的问题。重新启动工作室并避免在即时运行期间拉电缆以备将来重复此问题。

回答by Luca

I found this solution that works for me (AndroidStudio 2.1.3, Android 6.0.1). With the Android app running, without closing it on the connected device (smartphone/tablet), do the following steps:

我发现这个解决方案对我有用(AndroidStudio 2.1.3,Android 6.0.1)。在运行 Android 应用程序的情况下,无需在连接的设备(智能手机/平板电脑)上关闭它,执行以下步骤:

  1. Re-launch the Android app on AndroidStudio, with "Run" button (through the green right arrow);
  2. After 1 sec, press on "Stop" button (through the red square);
  3. AndroidStudio shows two different running processes: the already running Android app on on the connected device, and the Gradle compiling process;
  4. Stop the first one (the already running Android app on the connected device), and leave the Gradle process to complete the deployment of the new version of the Android app on the connected device.
  1. 使用“运行”按钮(通过绿色右箭头)在 AndroidStudio 上重新启动 Android 应用程序;
  2. 1 秒后,按下“停止”按钮(通过红色方块);
  3. AndroidStudio 展示了两个不同的运行过程:连接设备上已经运行的 Android 应用程序,以及 Gradle 编译过程;
  4. 停止第一个(已在连接设备上运行的 Android 应用程序),并离开 Gradle 进程以完成在连接设备上部署新版本的 Android 应用程序。

For me this solution works.

对我来说,这个解决方案有效。

回答by Luca

Another solution can be by selecting the Runbutton, the app on the device crashes, since it tries to reopen with an instance of itself already running, and then by selecting another time the Runbutton.

另一种解决方案是通过选择“运行”按钮,设备上的应用程序崩溃,因为它试图在自己的实例已经运行的情况下重新打开,然后再次选择“运行”按钮。

In this way the patches that need to be applied to the app will be compiled and the app restart with its new version.

这样,需要应用到应用程序的补丁将被编译,应用程序将以其新版本重新启动。