Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between :app:assembleRelease and 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

like image 836
zihadrizkyef Avatar asked Apr 02 '20 11:04

zihadrizkyef


People also ask

What is the difference between assembleRelease and bundleRelease?

Usage. I use assembleRelease to build an apk that I want to share with other people. I use installRelease when I want to test a release build on a connected device. I use bundleRelease when I am uploading my app to the Play Store.

What does Gradlew assembleDebug do?

The assembleDebug build task builds the debug version of your app and signs it with the default local certificate, so that you can install it on the emulator and on real devices for debugging purposes.

How to open cmd in Android Studio?

Open a command line—from Android Studio, select View > Tool Windows > Terminal—and navigate to the directory where your unsigned APK is located.


2 Answers

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

like image 53
Jeel Vankhede Avatar answered Oct 18 '22 06:10

Jeel Vankhede


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.

like image 20
Giorgio Antonioli Avatar answered Oct 18 '22 08:10

Giorgio Antonioli