简体   繁体   中英

Android buildTypes for Alpha/Beta/Production apk

I want to release my apk on play store. Initially I will release it on alpha, then beta and if everything goes well I will release it on production. Can we define different api endpoint for each in buildType inside gradle. if yes then how? As I just want to change the end point of API I am calling throughout my application. Like if I release my apk on alpha the api that it points will be http://test.alpha.bla.bla

for beta: http://test.beta.bla.bla

for production: 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.

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:

 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 )

you can then reference the server by using (in java)

BuildConfig.server; //this would be http://test.alpha.bla.bla

I would put it in strings.xml . Each build variant can have its own copy with a different value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM