Difference between :app:assembleRelease and assembleRelease
Asked Answered
A

2

11

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

Amplification answered 2/4, 2020 at 11:44 Comment(0)
F
12

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.

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

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


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.

Gradle Task Graph

Note that: In android you can have multiple modules but your default module is always abbreviated as app module while others are considered as library module which are abbreviated by name of that individual module like base, db, domain etc. from image above (You can't have multiple app module in same project I guess).

Fanfani answered 2/4, 2020 at 12:0 Comment(2)
what will be happened if i run :db:assembleRelease instead of :app:assembleRelease?Amplification
It would generate .aar (android archive format) file for that module library inside it's build directory.Fanfani
R
6

The difference between :app:assembleRelease and assembleRelease is that assembleRelease executes the assembleRelease task of each module while :app:assembleRelease executes the assembleRelease task in the app module.

Obviously the task graph is populated correctly for both, it means that :app:assembleRelease for Android depends on the assembleRelease of the other modules used as dependencies in :app.

Reynolds answered 2/4, 2020 at 11:59 Comment(2)
is it okay if i make an android apk for playstore with :app:assembleRelease instead of assembleRelease?Amplification
@Amplification If the APK you are upload on Play Store is the APK of the module app and you aren't manually manipulating the task graph, yes.Reynolds

© 2022 - 2024 — McMap. All rights reserved.