为什么Android Studio无法构建和部署正确的APK [英] Why is Android Studio not building and deploying correct apk

查看:154
本文介绍了为什么Android Studio无法构建和部署正确的APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题类似于此问题,但是应用程序部署.

My issue is similar to this question however the app is deployed.

当前在Windows上,当我单击运行"时,Android Studio Gradle开始按预期方式构建并显示已完成(有时会显示1条警告,有时,根据情况,我可能会收到有关卸载以前的APK的对话框)

Currently on Windows when I click run in the Android Studio Gradle starts building as expected and says completed (sometimes completed with 1 warning and sometimes, depending on the situation I may get a dialog about uninstalling the previous APK)

然后,该活动将按预期在设备或仿真器上启动,但是当我开始测试时,很明显没有部署最新的更改.安装无提示失败或已从构建缓存中部署了旧的APK.

Then the activity launches on the device or emulator as expected, but when I start testing it becomes obvious that the newest changes are not deployed. Either the installation has silently failed or an old APK from the build cache has been deployed.

我已关闭即时运行功能,但通常在运行更改之间不卸载应用程序,除非我更改了分支(Git),并且Android Studio告诉我版本不兼容.

I have instant run switched off but usually do not uninstall the app between running my changes, except where I have changed branches (Git) and Android Studio has told me the versions are incompatible.

通常,如果系统进入此状态,唯一有用的是 Invalidate Caches/Restart

Usually if the system gets into this state the only thing that helps is Invalidate Caches/ Restart

这是一个很难跟踪的问题,是否有人遇到过并且成功地阻止了它?

This is a hard issue to track, has anybody else encountered it and had success in preventing it?

推荐答案

我尚未找到防止这种情况的方法,但是以下方法似乎可以确保始终安装正确的APK:

I have not found a way to prevent this, but the following seems to work to ensure the correct APK is always installed:

  1. 从设备/模拟器卸载
  2. 运行Gradle/cleanBuildCache
  3. 运行Gradle/clean
  4. 部署

如果跳过cleanBuildCache,它将失败.单独清洁似乎做得不够.

If you skip cleanBuildCache it fails. Clean alone doesn't appear to do enough.

我仍在寻找更好的答案-如果有答案,请发帖

I'm still looking for a better answer - post if you have one

这篇关于为什么Android Studio无法构建和部署正确的APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆