Creating a Release Build in Android Studio

Published October 01, 2024

To generate a release build of your Android app, you need to sign it with a release key and configure it for release. Here's how you can do it in Android Studio

How to generate release build in android studio

 

Generate a Signed Bundle or APK

  1. In Android Studio, go to Build > Generate Signed Bundle / APK

  2. Choose either Android App Bundle or APK. App Bundles are generally recommended as they allow Google Play to generate optimized APKs on device for different device configurations. 

  3. If you don't have a keystore yet, create a new one:

    • Create New: If you don't have one, create a new keystore.

      • Fill in the required information for the keystore and key. Remember to store this keystore securely, as you'll need it for future updates to your app.

    • Existing Keystore: If you have one, select it and enter the passwords.

      • If you have an existing keystore, select Choose existing and locate your keystore file.

      • Enter the keystore and key passwords.

  4. Select the release build variant.

  5. Choose a destination folder for the output file.

  6. Click Finish

Optional: Build.gradle Configuration

Customize the release build in your module-level build.gradle file:

Gradle

android {

    buildTypes {

        release {

            minifyEnabled true

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),  

'proguard-rules.pro'

            signingConfig signingConfigs.release  

 

        }

    }

}

 

 

Explanation:

  • MinifyEnabled: Enables code shrinking.

  • ProguardFiles: Specifies Proguard configuration files.

  • SigningConfig: Links the release build to the release signing configuration.

By following these steps and customizing the build configuration, you can create a release-ready version of your Android app

 

 References

  • https://developer.android.com/studio/publish/preparing

  • https://developer.android.com/build/build-for-release

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

102 Views