Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio build configurations [duplicate]

I'm wondering how to create different build configurations, having different constants for debug and release builds using Android Studio (things like, server addresses, API keys,…).

like image 356
Tiago Fael Matos Avatar asked Jul 01 '13 10:07

Tiago Fael Matos


People also ask

What is build configuration in android?

The Android build system compiles app resources and source code, and packages them into APKs or Android App Bundles that you can test, deploy, sign, and distribute.

What is flavorDimensions?

Flavor Dimensions is a way to group flavors by a name. For now, we're using just a single group. Add the following line in your defaultConfig block: flavorDimensions "default" Now syncing the gradle would give you the following product flavors: Android Build Variants combine build types and product flavors.


1 Answers

Edit the build.gradle file in your module and add any of the following to your android{} container.

    signingConfigs {
        release {
            storeFile file("path relative to the root of the project")
            storePassword "PASSWORD!"
            keyAlias "projectname"
            keyPassword "PASSWORD!"
        }
    }


    buildTypes {
        debug {
            versionNameSuffix "-DEBUG"
            packageNameSuffix ".debug"
        }
        release {
            debuggable false
            signingConfig signingConfigs.release
        }
        debugRelease.initWith(buildTypes.release)
        debugRelease {
            debuggable true
            packageNameSuffix '.debugrelease'
            signingConfig signingConfigs.release
        }
    }

}

This adds 3 build types (release, debugRelease and debug)

both release and debugRelease use the same keys and debugRelease is a copy of Release.

like image 169
hoss Avatar answered Sep 27 '22 19:09

hoss