Search code examples
androidmdmairwatch

AirWatch complains App Version Code hasn't changed (but it has)


AirWatch believes the version code on the latest version of an apk has not been increased since the previous version.

We have recently upgraded the Android Studio build tools from 25.0.0.0 to 26.0.0.2 and the problem seems to be related to this change.

The version code is stored in the apk (which is a zip file) in a file AndroidManifest.xml. AndroidManifest.xml is a binary file.

What do I need to change to force Android Studio to write the version code to the apk AndroidManifest.xml in such a way that AirWatch will recognise it?

My app is using features of SDK 26 which means it would be very painful to revert to an earlier version that is supported by build tools 25.0.0.0.


Solution

  • Android's binary XML format supports 2 encoding for strings, UTF8 and UTF16.

    It seems that the current version of AirWatch only supports the UTF16 format.

    In earlier verisons of the Android build tools (specifically Gradle), strings were encoded in UTF16 and so AirWatch was able to extract the Version code.

    However, when using Gradle 3.0.0, the encoding changes to UTF8.

    Fortunately, you can change the build options to revert the encoding to UTF16 via a setting in the gradle.properties file (see this post).

    # AirWatch currently requires strings in the apk binary AndroidManifest.xml to be UTF16 encoded
    # When using Gradle 3.0.0, Aapt2 defaults to UTF8 encoding and setting this to false reverts to UTF16
    # NB: At some time in the future, the
    #     systemProp.file.encoding=UTF-16
    #     may be required to achieve the same outcome (but at the moment android.enableAapt2 is required)
    android.enableAapt2=false