What causes this Android APK Upload error: "Non-upgradable APK"
Asked Answered
F

6

28

I have an Android APK in the Google Play store with an Target SDK of 23.

I have released a new version (same target SDK) and Google shows me this error:

If I proceed (I learnt the hard way) then none of the current users can upgrade to this version. I had to restore the code, increment the build number and rebuild the APK to "rollback" to a usable version.

However, I cannot work out WHY google is showing me this error. Note, the "0 Supported Android Devices" is a red-herring - it is a known issue in Google Play in the last 24 hours - if you publish the APK the real number of devices is shown.

Please give me some leads on what the difference is or what causes this error:

Non-upgradable APK WARNING None of the users of this APK will be able to upgrade to any of the new APKs added in this release. TIP Ensure that all your new APKs are added to this release. enter image description hereenter image description here enter image description here

Fioritura answered 19/5, 2017 at 4:47 Comment(2)
Also in new version it shows Supported Devices = 0Celesta
That is a Google Play bug (and unrelated I believe), see -#44049769Fioritura
C
55

I got able to resolve this issue:-

The issue was with the versioncode - I am sure you have not defined any version code in your App and it is getting generated by this formula:

 versionCode = MAJOR * 10000 + MINOR * 100 + PATCH

But sometimes auto generated versioncode value of the latest release becomes smaller than the previous release (in your case 10403 < 104028) and that's why it shows non-upgradable APK.

What you need to do is:-

In your config.xml in tag add versioncode like below:-

android-versionCode="104280" 

104280 will work for you as it is greater than older version.

Now get it published without any error.

Thanks Sanny

Celesta answered 19/5, 2017 at 12:32 Comment(4)
Hmmm that sounds plausible! Let me try that out and confirm - thanksFioritura
Glad it helped.Celesta
this is happening after switching form apk to app bundles.Musclebound
This bug still exists in Google Play today. I went from 1.0.3 (52) of my app to 1.0.5 (4) and it complained. Changed it to 1.0.5(54) and it's fine.Jiles
I
8

I'm using VS-TACO and ran into this problem.

To slightly clarify Sanny's answer which fixed the issue for me. Apparently, somewhere along the way the android-versionCode was calculated using this formula:

MAJOR * 100000 + MINOR * 1000 + PATCH * 10

but now it is getting calculated using the version Sanny shows:

MAJOR * 10000 + MINOR * 100 + PATCH

So for example if your version was 1.3.1 android-versionCode was calculated as "103010"

now you change the version to 1.3.2 and it is calculated the new way so the version is "10302" which is less than "103010".

So to work around this issue (I guess forever if the android version keeps getting calculated the new way) you can add the version tag to your config.xml:

<?xml version="1.0" encoding="utf-8"?>
<widget android-versionCode="103020" ...

or you can go into Visual Studio and use the visual editor for config.xml, go to the "Android" section and change the "Version Code:" value.

Istle answered 5/7, 2017 at 11:32 Comment(2)
Thanks for the clarification - unfortunately this means from now on every release I have to increment this manually...Fioritura
Its so weird how android calculates the version. I had to use something like 4.4001 after using 4.3 in my previous version.Brachypterous
W
1

I ran into a similar problem but was able to solve it with the following Node script used as part of my continuous deployment pipeline.

Note:

This reads from a VERSION.md file that contains the current app version.

It may also be run with the --version argument to only update the current version in config.xml without setting the build versions.

#!/usr/bin/env node

var fs = require('fs');
var xml2js = require('xml2js');
const cliArgs = require('command-line-args');
const options = cliArgs([
    {name: 'version', type: Boolean}
]); 

// Read config.xml
var xml = fs.readFileSync('config.xml', 'utf8');

// Parse XML to JS Obj
xml2js.parseString(xml, function (err, result) {
    if(err) {
        return console.log(err);
    }

    // Get JS Obj
    var obj = result;
    const version = fs.readFileSync('VERSION.md', 'utf8');

    if (options.version){
        // Write current version
        obj['widget']['$']['version'] = version;
    } else {
        // Increment build numbers (separately for iOS and Android)
        obj['widget']['$']['ios-CFBundleVersion'] = version;
        // remove all periods to create an integer for Android
        const [major, minor, patch] = version.split('.')
        obj['widget']['$']['android-versionCode'] = major+pad_number(minor)+pad_number(patch);
    }

    // Build XML from JS Obj
    var builder = new xml2js.Builder();
    var xml = builder.buildObject(obj);

    // Write config.xml
    fs.writeFile('config.xml', xml, function(err) {
        if(err) {
            return console.log(err);
        }
        
        console.log('Build number successfully incremented');
    });

});

/**
 * Pad a number with prepending zeros if less than 10
 * @see [Javascript function to pad a string](https://mcmap.net/q/10178/-is-there-a-javascript-function-that-can-pad-a-string-to-get-to-a-determined-length)
 */
function pad_number(orig) {
    return ("00"+orig).slice(-2);
}
Weltanschauung answered 5/11, 2017 at 3:15 Comment(0)
J
1

I just had the same issue with the versions, as I upgraded react-native to 0.60.5 So I calculated the differences between missing versionCode version

Version 1.9 = VersionCode => 4194313

Version 1.10 = VersionCode = 3145739

Difference : 194313 - 3145739 = 1048574

Each APK per architecture will use that formula

versionCodes.get(abi) * 1048576 + defaultConfig.versionCode

I have modified a little bit my formula

versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + 1048574

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + 1048575;
        }

    }
Joannejoannes answered 6/9, 2019 at 22:39 Comment(0)
D
0

For those of you using Android Studio, I had this problem after upgrading from Eclipse to Android Studio and not configuring the gradle files properly.

Make sure the version code in your build.gradle in defaultConfig{} is correct.

...
defaultConfig {
    ...
    versionCode 373
    versionName "3.73"
Doable answered 2/8, 2017 at 9:51 Comment(0)
C
0

I ran into this issue because in my cordova config.xml the previous version was 0.0.51 and the new version was 0.0.6. But in the playstore console, those numbers were converted to 51 and 6 for the APK number. One can't "upgrade" from 51 to 6. So I changed the xml to be 0.0.60, which made the APK number 60, and voila, I can update from 51 to 60.

Cima answered 15/9, 2017 at 4:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.