当 outputDirectory 或 outputFileName 更改时,AS 在启动调试应用程序时找不到 apk [英] AS can not find the apk when starting debug app when outputDirectory or outputFileName changed

查看:46
本文介绍了当 outputDirectory 或 outputFileName 更改时,AS 在启动调试应用程序时找不到 apk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Android Studio 调试我的应用程序.由于某些原因,我必须更改默认输出 apk 目录和文件名.所以我在应用程序的 build.gradle 脚本中更改了 applicationVariants 的 outputDirectory 和 outputFileName.此修改使 apk 输出到预期的位置和名称.但是我发现一个问题是,当我像以前一样开始调试应用程序时,AS说:

I am using Android Studio to debug my application. For some reasons, I have to change the default output apk directory and file name. So I changed the applicationVariants' outputDirectory and outputFileName in app's build.gradle script. This modification make the apk output to the expected place and name. But I found a problem is that when I start to debug the app just like before, AS said:

Installation did not succeed.
The application could not be installed.

List of apks:
[0] 'C:\Users\progquest\projects\Study\app\build\outputs\apk\free\debug\app-free-debug.apk'
Installation failed due to: 'Invalid File: C:\Users\progquest\projects\Study\app\build\outputs\apk\free\debug\app-free-debug.apk'

注意:免费"是我的应用程序的一种产品风格.

Note: 'free' is a product flavor of my application.

显然,调试器仍然使用旧的默认输出目录和apk文件名来查找源apk.怎么改?

Obviously, the debugger still used the old default output directory and apk file name to find the source apk. How to change it?

谢谢.

推荐答案

这发生在我身上;在我取消选择然后重新选择正确的Active Build Variant"后,它再次开始工作;在构建变体"中工具(即使它已经被选中).

This happened to me; it started working again after I unselected and then re-selected the correct "Active Build Variant" in the "Build Variants" tool (even though it was already selected).

这篇关于当 outputDirectory 或 outputFileName 更改时,AS 在启动调试应用程序时找不到 apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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