13

Is it possible for the app to determine in what environment of Google Play the app is released?

I want to know if the app is located in the alpha, beta or production channel so i can use different API urls for each of the environments, like so:

  • alpha - test.example.com/api/login

  • beta - staging.example.com/api/login

  • production - example.com/api/login

Right now i have to upload many different APK's and increment the versionCode to use the 3 different channels. So is it possible to determine the channel it was uploaded to?

AuStrike
  • 421
  • 1
  • 5
  • 19
  • Why do you want to do that. One apk is good enough. First upload to alpha channel, then keep promoting it to beta and production. – drulabs Apr 18 '16 at 08:50
  • Because if i will transfer the alpha APK to beta, the app will still connect to test.example.com/api/login. While i want it to connect to staging.example.com/api/login on beta – AuStrike Apr 18 '16 at 09:08
  • Got it. I think what you need is product flavors. earh flavor pointing to alpha, staging and production. Here check out my blog post. https://androiddevsimplified.wordpress.com/2016/04/06/gradle-power-android-product-flavours-and-configuration/ – drulabs Apr 18 '16 at 09:11
  • And if you want to generate version name and code automatically. https://androiddevsimplified.wordpress.com/2016/04/16/gradle-power-automatically-generate-android-app-version-code-and-name/ – drulabs Apr 18 '16 at 09:12
  • And about your question. Man you have base urls pointing to different urls. you can use that to figure which channel it was uploaded to. – drulabs Apr 18 '16 at 09:15
  • I would say the point is to only have 1 APK and then you can use the promote button to use the same APK but in a different environment. This would be quite useful I think. – deive Mar 23 '18 at 10:29
  • @deive Did anyone find a solution here? Being able to determine environment at runtime would be very useful... – j_d Jul 16 '18 at 12:28
  • @IsaacHinman Unfortunately not - I have not had the time to play with this, so we have settled on testing debug outside of Google Play, then uploading the live to the Internal Testing track for full smoke test, then when this is passed promoting up the tracks. Still would like to know if this is possible though! – deive Jul 16 '18 at 14:09
  • @IsaacHinman Like deive said, unfortunately not.. We were forced to make some build servers which would build and deploy on the correct channel, so theres less room for human error. – AuStrike Jul 16 '18 at 15:07

2 Answers2

2

You can't, as far as I know. Besides if it was installed from beta you could later make that as the normal release anyways - so it's not the install source, but where it is currently that matters. What you're doing is not alpha/beta testing in the sense that it's in the play store.

But you could guess if it's the public version by checking from the store listing if the version number is greater than that.

Is it possible to detect that an android app is either a beta version or production version? has some links into a google developer api to do basically just that(though I'm pretty sure you could just scrape it off the web too).

All and all the system isn't really meant for staging testing in that sense where you would have them connect to a different environment, so you might just be better off planning your testing again. It's more suited for actual beta testing before committing to updating all users of the application.

What could be an option for you then would be to create entirely different private products for each of the different servers/tracts you have (you'll need to change the app id though for those builds, but that might be for the better).

edit: you can greatly simplify my first suggested solution/hack if you make the compromise of having the latest versions name be served from your own server, so you can check if your version number is greater than that then connect to beta,alpha or whatever api. This will complicate making the actual release as you need to remember to change this, however it would allow you to test the beta version on the actual production server too then before promoting it to the full release status.

Lassi Kinnunen
  • 448
  • 4
  • 10
1

I see two options here. You can :

  • add an in-app runtime mechanism to change environment. By default the app would use production env but you can change it using a hidden/secured menu
  • upload a version on google play for each environment. You do some alpha/beta testing using test or staging environment and when everything is ok you promote the production build. Still, you need to think carefully your package names or version codes...

Hope it helps :)

BenjO
  • 33
  • 7
  • I agree with the first one. We will be doing the method nr.1. In login screen just add DEVemail@gmail.com and the app will work in DEV enviroments. But its sto strange that there isnt a better solution for this provided by google. Nr.2 is sketchy, you could accidentally push DEV build to Live. – paakjis Jan 05 '23 at 10:57