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
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.
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.
Open a command line—from Android Studio, select View > Tool Windows > Terminal—and navigate to the directory where your unsigned APK is located.
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.
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).
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With