Configure Build Types


You can create and configure build types in the module-level  build.gradle file inside the android {} block. When  you create a new module, Android Studio automatically creates the debug and  release build types for you. Although the debug build type doesn't appear in  the build configuration file, Android Studio configures it with  debuggable true. This allows you to debug the app on secure  Android devices and configures APK signing with a generic debug keystore.

You can add the the debug build type to your configuration if you want to add  or change certain settings. The following sample specifies an  applicationIdSuffix for the debug build type, and configures  a "jnidebug" build type that is initialized using settings from the  debug build type.

android {
   
...
    defaultConfig
{...}
    buildTypes
{
        release
{
            minifyEnabled
true
            proguardFiles getDefaultProguardFile
('proguard-android.txt'), 'proguard-rules.pro'
       
}

        debug
{
            applicationIdSuffix
".debug"
       
}

       
/**
         * The 'initWith' property allows you to copy configurations from other build types,
         * so you don't have to configure one from the beginning. You can then configure
         * just the settings you want to change. The following line initializes
         * 'jnidebug' using the debug build type, and changes only the
         * applicationIdSuffix and versionNameSuffix settings.
         */


        jnidebug
{

           
// This copies the debuggable attribute and debug signing configurations.
            initWith debug

            applicationIdSuffix
".jnidebug"
            jniDebuggable
true
       
}
   
}
}

Note: When you make changes to a build configuration file,  Android Studio requires that you sync your project with the new  configuration. To sync your project, you can click Sync Now  in the notification bar that appears as soon as you make a change or  Sync Project from the toolbar. If Android  Studio notices any errors with your configuration, the  Messages window appears to describe the issue.

To learn more about all the properties you can configure with build types,  read the  build type DSL reference.