embleRelease和assembleRelease之间的区

embleRelease和assembleRelease之间的区

本文介绍了:app:assembleRelease和assembleRelease之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的android项目中有多个模块.如果我使用:app:assembleRelease进行发布apk,则可以,但是当我使用assembleRelease进行发布apk时,它会继续显示错误.我知道我的代码中有错误,但这不是我要问的问题.我只想知道assembleRelease:app:assembleRelease

I have mutiple modules in my android project. if i make a release apk with :app:assembleRelease it works but when i make a release apk with assembleRelease it keep showing error. I know there's error in my code but this is not what i am questioning about. I just want to know what is the difference between assembleRelease and :app:assembleRelease

推荐答案

在Multi module Gradle项目中,如果您未明确引用模块 ,则Gradle默认尝试从以下位置查找该任务根项目的任务"图.

In Multi module Gradle project, if you don't refer to your module explicitly then Gradle by default try to find that task from root project's Tasks graph.

例如:如果您有多个名为 module1 &的模块, module2 ,然后在评估阶段,Gradle将每个模块的任务分配到各自的扩展中.意味着您现在必须将其称为 :module1:task1 & :module2:task2

For example: If you're having multiple modules named as module1 & module2, then on evaluation phase Gradle distributes each module's tasks in their own extensions. Meaning you must now refer it as :module1:task1 & :module2:task2

这是assembleRelease无法正常工作的原因& :app:assembleRelease有效.

This is the reason why assembleRelease doesn't work & :app:assembleRelease works.

您可以通过在Android Studio/IntelliJ IDEA中打开成绩"窗口来检查任务图.

You can check tasks graph by opening 'Gradle' window in Android Studio/IntelliJ IDEA.

如果您查看下面的图像,则可以看到任务"节点,这些节点在根项目中具有可用的常见任务.

If you look at the image below you can see Tasks node which have common tasks available at root project.

在扩展它自己的节点时,还可以找到其他与模块相关的任务.

While there are other module related tasks can be found inside expanding it's own node.

请注意 :在android中,您可以有多个模块,但默认模块始终缩写为应用程序模块,而其他模块则被视为库模块,并以的名称缩写 .上方的图像中的单个模块,如基础,数据库,域等.(我猜您不能在同一项目中有多个应用程序模块).

这篇关于:app:assembleRelease和assembleRelease之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 02:59