Android buildTypes multiple debug modes

900 views Asked by At

I have three build types, and I am trying to get the staging build type to run but I am getting the following error:

Error: The apk for your currently selected variant (app-staging-unsigned.apk) is not signed. Please specify a signing configuration for the variant (staging).

Is there a way for me to run staging without signing, as like a second debug?

android {
     buildTypes {
        debug {
            buildConfigField "String", "SERVER", '"dev.gamesmart.com"'
        }
        staging {
            buildConfigField "String", "SERVER", '"staging.gamesmart.com"'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "SERVER", '"gamesmart.com"'
        }
    }   
}
1

There are 1 answers

1
CommonsWare On BEST ANSWER

Try:

android {
     buildTypes {
        debug {
            buildConfigField "String", "SERVER", '"dev.gamesmart.com"'
        }

        staging.initWith(buildTypes.debug)

        staging {
            buildConfigField "String", "SERVER", '"staging.gamesmart.com"'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "SERVER", '"gamesmart.com"'
        }
    }   
}

This says "have staging start as a clone of debug, then we'll modify from there", so staging should apply the debug signing config.