[英]Android buildTypes for Alpha/Beta/Production apk
I want to release my apk on play store. 我想在Play商店上发布我的APK。 Initially I will release it on alpha, then beta and if everything goes well I will release it on production.
最初,我将在alpha上发布它,然后在beta中发布,如果一切顺利,我将在生产中发布它。 Can we define different api endpoint for each in buildType inside gradle.
我们可以在gradle中的buildType中为每个API定义不同的api端点。 if yes then how?
如果是,那怎么办? As I just want to change the end point of API I am calling throughout my application.
因为我只想更改API的终点,所以我在整个应用程序中都在调用。 Like if I release my apk on alpha the api that it points will be http://test.alpha.bla.bla
就像我在alpha上发布我的apk一样,它指向的api将是http://test.alpha.bla.bla
for beta: http://test.beta.bla.bla 测试版: http://test.beta.bla.bla
for production: http://test.production.bla.bla . 用于生产: http://test.production.bla.bla 。
so in this my all version of app (alpha/beta/production) will be having same version code without any need to upload new apk. 因此,在此情况下,我的所有版本的应用程序(alpha / beta / production)将具有相同的版本代码,而无需上传新的APK。
Thanks. 谢谢。
I assume that you mean you want 3 different build targets (and thus 3 different uploads to google play): in your build.gradle you have the android part, in there you can define productFlavors like the following: 我假设您的意思是您想要3个不同的构建目标(因此需要3个不同的上载到Google Play):在build.gradle中,您具有android部分,您可以在其中定义productFlavors ,如下所示:
productFlavors{
alpha{
buildConfigField 'string', 'server','http://test.alpha.bla.bla'
}
}
But you could also make enums and refere those (instead of the type "string" you would have to specifiy the full package name + enum type , and in the last part (the value), the full package name + enum ) 但是您也可以创建枚举并引用这些枚举(而不是类型“ string”,您必须指定完整的包名+枚举类型,最后一部分(值)是完整的包名+枚举)
you can then reference the server by using (in java) 然后您可以使用(在Java中)引用服务器
BuildConfig.server; //this would be http://test.alpha.bla.bla
I would put it in strings.xml
. 我会将其放在
strings.xml
。 Each build variant can have its own copy with a different value. 每个构建变体可以具有不同值的自己的副本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.