Android Studio 3.1“运行"不编译代码 [英] Android Studio 3.1 "Run" not compiling code

查看:674
本文介绍了Android Studio 3.1“运行"不编译代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试安装应用程序时,有两种可能性:

When I try to install an app, there are two possibilities:

  1. 当我运行app
  2. 时,从build文件夹安装现有的APK
  3. 执行clean build
  4. 后安装APK
  1. Install existing APK from build folder when I run the app
  2. Install APK after performing clean build

对于build文件夹中的现有APK,该应用程序可以正常运行.但是当我使用Build-> Clean Project清理项目,然后尝试运行app(即将应用程序安装到仿真器或物理设备上)时,它显示了错误:

For existing APK in the build folder, the app just works fine. But when I clean the project using Build -> Clean Project, and then try to run the app (i.e. install the app to my emulator or physical device), it shows me error:

APK文件/Users/MyApplicationName/app/build/outputs/apk/app-debug.apk在磁盘上不存在.

The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk.

注意:仅当我清理项目时才会发生此行为,而在构建文件夹中已经有预构建的应用APK时则不会发生

我已提及: APK文件在磁盘上不存在,但我的意思是,当我们通常运行该应用程序时清理项目后,我们无需构建它,如果build文件夹中不存在APK,它将自动生成并安装最新的APK.

I've referred to: The APK file does not exist on disk but my point is, when we usually run the app after cleaning the project, we never need to make a build of it, if the APK is not existing in the build folder, it automatically generates and installs the latest one.

我尝试过的事情:

  1. 在构建文件夹中存在APK文件时运行应用程序(工作正常)
  2. 运行Clean Project->运行应用程序(预计将生成项目并安装应用程序,但显示上述错误!)
  3. 执行Invalidate Caches/Restart
  4. 后,清理和运行应用程序的过程相同
  1. Running the app when APK file exists in the build folder (works perfectly fine)
  2. Running the Clean Project -> Running the app (expected is the project would be built and the app would get installed but it shows the above mentioned error!)
  3. Same process of cleaning and running the app after doing Invalidate Caches/Restart

推荐答案

对于您的问题,我有解决方案.希望对您有帮助!

I have solution for your issue. Hope it helps!

还由 Android Studio Twitter 上确认: https://twitter.com/androidstudio/status/981914632892960768

1)请按如下所示编辑您的应用配置.

1) Please edit your app configuration as below.

2)在这里,您可以看到如下的应用程序配置.

2) Here you can see your app configuration as below.

3)在启动配置之前,这里缺少Gradle-aware的make属性.你可以在这里看到.

3) Here is missing Gradle-aware make attribute in before launch configuration. You can see here.

4)请通过这种方式添加此Gradle-aware的Make属性.点击+图标,然后选择Gradle-aware Make(在此屏幕中看到).

4) Please add this Gradle-aware Make attribute through this way. Click on + icon and select Gradle-aware Make as seen in this screen.

5)您可以在不编写任何任务的情况下添加它,只需按OK按钮,任务将被添加,现在看起来应该像这样.现在应用更改并运行您的应用程序.

5) You can add this without writing any task just press OK button and task will be added and now it should look like this. Now apply changes and run your application.

希望它将在新的android studio 3.1问题中的干净版本上解决这个旧的apk安装问题.

Hope it will solve this old apk installing issue on clean build in new android studio 3.1 issue.

注意::此问题已在新的 Android Studio 3.1.1 稳定版本中解决.

Note : This issue is resolved in new Android Studio 3.1.1 Stable release.

快乐编码!

这篇关于Android Studio 3.1“运行"不编译代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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