问题
I have the follow situation
Scenario
Part 1. An app working with Build Variants
: debug
, beta
and release
as follow
buildTypes {
debug {
versionNameSuffix '-DEBUG'
applicationIdSuffix '.debug'
buildConfigField "String", "SERVER_URL", '"url local test"'
debuggable true
signingConfig signingConfigs.config
}
beta {
versionNameSuffix '-BETA'
buildConfigField "String", "SERVER_URL", '"url homologation"'
signingConfig signingConfigs.config
}
release {
buildConfigField "String", "SERVER_URL", '"url production"'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
And a call to use String SERVER_URL
pointing to current url by buildType selected
. Look this
String URL = BuildConfig.SERVER_URL
Part 2. The switch between Build Variants
by Android Studio, as follow image
It's working absolutelly fine for me
Issue
Part 1. I have the app on Google Play production generated as signed apk from release variant
Part 2. I need put the app on Google Play beta test generating as signed apk from BETA variant, e.g, pointing to url homologation
Part 3. When the product owner finish the tests from beta test, I go need promote the same app to production by Google Play Console
Question
The core question: When I go promote the app from beta to production, it one will point automatically to url production
by release variant
or I will need generate another apk as signed apk from release variant
?
Why? The main motivation is beacause I can't test this promotion without safe assurance that it will work fine, and no less important, this would save my time and my own chef would can do it
Alert! If it is wrong job, what the best pratice to do it?
回答1:
If I understand your question it is this:
- with your current setup, you have some configuration compiled into the APK, including a server URL
- you want to test with one server in beta, and a different one in release
- but this means you can't promote your beta APK to release, because the URL would be different. But if you re-compile, you can't be sure the APK remains unchanged from the one you tested.
You are right, this is a real problem. There are two common solutions:
- Option 1: don't compile your server strings into your APK. Instead, use a service like Firebase remote config to dynamically change the server and other settings for your beta. That way the APK doesn't need to change
- Option 2: When you build your beta build, tag your branch in your version control system. Then when you want to promote to prod, build a new APK, but make sure you are using the tagged branch from the version control system.
Personally I think I would recommend option 1, but I know different large professional android developers use both options.
来源:https://stackoverflow.com/questions/51499455/promotion-of-app-from-beta-to-production-on-google-play-working-with-build-varia