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

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

问题描述

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

  1. 当我运行 app
  2. 时从 build 文件夹安装现有的 APK
  3. 执行clean build后安装APK

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

<块引用>

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

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

我提到:

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

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

4) 请通过这种方式添加这个 Gradle-aware Make 属性.点击 + 图标并选择 Gradle-aware Make,如该屏幕所示.

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

希望它能在新的 android studio 3.1 问题中解决这个旧的 apk 安装问题.

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

快乐编码!!

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

  1. Install existing APK from build folder when I run the app
  2. Install APK after performing clean build

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:

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

NOTE: This behaviour happens only when I clean the project and not when I have already have a pre-built app APK in my build folder

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.

Things I've tried:

  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!

Also confirmed by Android Studio on Twitter : https://twitter.com/androidstudio/status/981914632892960768

1) Please edit your app configuration as below.

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

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

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) 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.

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

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

Happy Coding!!

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

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