Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between gradlewAssembleRelease, gradlewInstallRelease, and gradlew bundleRelease and when to use which?

When I want to upload an Android application to the Play Store, which one should I use?

I have tried the above but I am still confused about which one is the most effective?

./gradlew assembleRelease ./gradlew installRelease ./gradlew bundleRelease 

I expect the best way to do the above.

like image 222
zidniryi Avatar asked Jul 17 '19 09:07

zidniryi


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 is Gradlew bundleRelease?

./gradlew bundleRelease. Gradle's bundleRelease will bundle all the JavaScript needed to run your app into the AAB (Android App Bundle).

What does Gradlew clean do?

it removes build folder, as well configure your modules and then build your project. i use it before release any new app on playstore.

What does Gradlew assemble do?

Assemble is for creating artifacts (eg WAR or JAR) from the various components, classpaths, resource files, etc.


1 Answers

Most of the answers that you are looking for can be found here

assembleDebug

This builds an apk for your project using the debug variant.

This creates an APK named module_name-debug.apk in project_name/module_name/build/outputs/apk/. The file is already signed with the debug key and aligned with zipalign, so you can immediately install it on a device.

installDebug

This builds an apk for your project using the debug variant and then installs it on a connected device

Or to build the APK and immediately install it on a running emulator or connected device, instead invoke installDebug

assembleRelease

This creates a release apk of your app. You would then need to sign it using the command line or by setting the signing details in your build.gradle (see below) and then you can install it on your device using adb.

The steps involved for signing an apk by the command line are fairly long and it can depend on how your project is set up. Steps for signing can be found here

bundleRelease

This creates a release aab, this is Google's preferred format for uploading to the Play Store.

Android App Bundles include all your app’s compiled code and resources, but defer APK generation and signing to Google Play. Unlike an APK, you can't deploy an app bundle directly to a device. So, if you want to quickly test or share an APK with someone else, you should instead build an APK.

Signing your apk/aab

You can configure your app/build.gradle so that signing will be done after your build has been completed.

In your app/build.gradle

android {     ...     defaultConfig { ... }     signingConfigs {         release {             // You need to specify either an absolute path or include the             // keystore file in the same directory as the build.gradle file.             storeFile file("my-release-key.jks")             storePassword "password"             keyAlias "my-alias"             keyPassword "password"         }     }     buildTypes {         release {             signingConfig signingConfigs.release             ...         }     } } 

You can read more about signing your app here

Now, when you build your app by invoking a Gradle task, Gradle signs your app (and runs zipalign) for you.

Additionally, because you've configured the release build with your signing key, the "install" task is available for that build type. So you can build, align, sign, and install the release APK on an emulator or device all with the installRelease task.

installRelease

You will have to have set up the signing above for this to work for a release build. It is the same as the installDebug but it creates a signed release variant and installs it on a connected device.

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.
like image 181
Andrew Avatar answered Sep 22 '22 18:09

Andrew