5

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

Tiago Fael Matos
  • 2,077
  • 4
  • 20
  • 34

1 Answers1

6

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.

hoss
  • 2,430
  • 1
  • 27
  • 42