8

Background

Android application has 2 version: 1 for mobile devices, 1 for Android TV.
Android TV APK version code should be significantly higher than mobile devices Android APK version code.
APK for mobile devices has version codes like 10, 11, 12, etc.
APK for Android TV devices has version codes like 10001, 10010, etc.

Since both these APK's are published via one app configuration in Google Play, we have "shared" alpha/beta tracks. And when we release we just retain multiple APK's (1 for TV and 1 mobile devices).

I want to upload APK to Google Play alpha/beta track using Google Play API either using Gradle plugin or Jenkins plugin.
It doesn't matter which approach I'm choosing, I'm getting an error when I'm trying to upload APK for mobile devices.

Upload failed: - Devices with version 10002 of this app would be downgraded to version 54 if they met the following criteria: [(API_LEVEL in range 19-0 AND RELEASE_TRACK containing any of each of [[BETA]] AND SCREENS containing any of each of [[small, normal, large, xlarge]] AND NATIVE_PLATFORM containing any of each of [[x86_64, x86, armeabi-v7a, arm64-v8a]] AND GL_ES_VERSION in range 131072-0 AND FEATURES containing all of [android.hardware.screen.portrait, android.software.leanback, android.hardware.faketouch])].

This error clearly says that I can't upload APK with 54 version code (mobile device) since APK with 10002 version code (Android TV) is already in Google Play.
But Google Play allows me to accomplish this manually (through Google Play console UI) - create beta release with APK (54 version code) and retain existing APK in beta (10002 version code).

Question

Is it possible to upload APK for mobile device and for Android TV devices through Google Play API?
Is there any way to upload APK for mobile device to alpha/beta track and automatically retain APK from alpha/beta track which was there before upload?

Veaceslav Gaidarji
  • 4,261
  • 3
  • 38
  • 61
  • please follow this documentation. https://developers.google.com/android-publisher/ – Amrish Kakadiya Mar 18 '18 at 12:08
  • @AmrishKakadiya did you even read my question? – Veaceslav Gaidarji Mar 18 '18 at 16:27
  • have you try to use split method for making different apk – Amjad Khan Mar 23 '18 at 10:59
  • How do you differentiate between mobile and TV APK besides version code? My point is the TV APK should have `` so it can be installed only on TVs. This way Play store has a way to differentiate between your mobile APK which can be installed anywhere and your TV APK which can be installed only on TVs (and will be preferred on supported devices due to higher version code). – Eugen Pechanec Mar 23 '18 at 11:33
  • yes, Android TV has the leanback feature specified (it's mandatory for TV apps). – Veaceslav Gaidarji Mar 23 '18 at 14:40
  • @AmjadKhan I didn't try with split apk's. 1 APK for mobile devices (native), 1 APK for TV (built using Unity). And the fact that I can perform mixed release from Google Play Console UI, makes me feel it should be possible via API as well. – Veaceslav Gaidarji Mar 23 '18 at 14:48
  • you can refere this may this help you https://stackoverflow.com/questions/47302063/generating-multiple-apk-according-to-the-native-abi – Amjad Khan Mar 24 '18 at 03:39

1 Answers1

1

At first i would suggest giving the Mobile app a version number in the same number range as in the Tv app - Example:

// map for the version code
    project.ext.versionCodes = ['tv': 1, 'mobile': 2]
    android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.versionCodeOverride =
                    project.ext.versionCodes.get(output.getFilter(
                            com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode
        }
    }

As users will always get the higher version number vended to them you need the higher version number will have the criteria for the mobile devices and the lower version is a fallback to all devices that failed to qualify. You can also create specific flavours if a bit more grained control is needed. I'm using splits based on ABI as well as using Triple-T plugin for that matter and this works for all the versions i deploy.

MaTriXy
  • 1,659
  • 1
  • 20
  • 27
  • Even though it doesn't help me in my case (2 separate projects), it should work for others who have 1 project. In case of separated projects, I would need to externalize version code somewhere and consume it from 2 projects or in Jenkins jobs for mobile/TV projects. – Veaceslav Gaidarji Mar 26 '18 at 10:50
  • you would just need to write the same code on both projects gradle files and add the version number in a single file shared among these projects. or set the version number in Env. – MaTriXy Mar 27 '18 at 16:07