Detect the stage of the app (alpha, beta or production)

2.2k views Asked by At

I'm developing an android app using cordova and I wish to use the three given stages to release it gradually:

  • Alpha for IT tests
  • Beta for partners
  • Production for everyone else

However, I'm using mixpanel to track some user inputs. Mixpanel requires a token to work and I have 2 of them, one for beta and other for production, it is loaded with mixpanel.init("token1") when the app starts.

Currently, I build an apk with no token defined to run in alpha, then I build another one with token1 to run in beta, and later on another apk with token2 to run in prod. It works, but it's a pain.

I wish to use the promote option inside the Google Play Developer Console, so I could build one single apk (automated) that gets promoted to beta/prod when needed and knows which stage it is in, so it uses the token accordingly.

Is it possible? If not, is there a better way to make it work?

TL;DR Want to know which stage (alpha/beta/prod) the app is running in so it uses a token variable accordingly.

1

There are 1 answers

1
MSpeed On

I'm not sure if this will help but are you using build.gradle to make different product flavours? You can make it so that it will generate a class with different final constants in each type of build.

So for your prod build, you can do something like this:

prod {  
applicationId "zuul.com.android"
buildConfigField 'String', 'HOST', '"http://api.zuul.com"'
buildConfigField 'String', 'FLAVOR', '"prod"'
buildConfigField "boolean", "REPORT_CRASHES", "true"
}

and it comes out like this:

BuildConfig.HOST  
BuildConfig.FLAVOR  
BuildConfig.REPORT_CRASHES  

And then you can have one for dev, beta, or whatever.

Check out these links:

http://blog.brainattica.com/how-to-work-with-flavours-on-android/

Deploying multiple build variants at a time - Android studio gradle