0

I would like to install one single instance of my app with every build type contained within that app. I have seen plenty of posts of installing multiple build types like Android Gradle: Install all build types on one device, and https://medium.com/yplan-eng/how-to-have-debug-beta-and-prod-builds-installed-at-the-same-time-696ec4c76211. But this will actually create two versions of the app with different names and suffixIds.

So this is what I've tried essentially:

defaultConfig {
    ...
    resValue "string", "app_name", "MyApp"
}
signingConfigs {
    release {
        storeFile file('../key-store')
        storePassword ANDROID_KEYSTORE_PASSWORD
        keyAlias 'key0'
        keyPassword ANDROID_KEYSTORE_PASSWORD
    }
}
buildTypes {
    debug {
        applicationIdSuffix = ".debug"
        resValue 'string', "app_name", "MyApp DEV"
        buildConfigField 'String', 'BASE_URL', '"https://real.api/dev1"'
    }
    QA {
        applicationIdSuffix = ".QA"
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        resValue 'string', "app_name", "MyApp QA"
        buildConfigField 'String', 'BASE_URL', '"https://real.api/qat1"'
    }}

This is the code that allows different instantiations of the app with different names/builds. What I would like is one app, with one name, and the ability as a user to somewhere in my app choose which build I would like the app loaded as.

Is this possible? Any pointing the right direction would be very helpful. I'm not looking for an UI implementations, just how I set this up with gradle, and how to select the build type the app is supposed to be loading. Thanks in advance.

dougie
  • 53
  • 8
  • Have you considered an initial configuration screen that displays the first time the app is launched that simply uses shared preferences to hold user choices for things like base URL, log level, etc? Would avoid the need for different gradle build types embedded in the same APK, which I'm fairly certain isn't possible. – Greg Moens Jan 22 '19 at 03:52
  • I actually haven't considered that yet, I'm definitely open to it. But I'm curious if what I'm suggesting has been done using build types. – dougie Jan 22 '19 at 06:22
  • @GregMoens I don't think what you're suggesting is possible if I'm building a retrofit object in a dagger module. That gets built during the build, so either way I would have to try and do some type of UI interaction before a build. And I'm not sure if that's possible. – dougie Jan 22 '19 at 20:10

0 Answers0