AirWatch 抱怨 App Version Code 没有改变(但它有)

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

AirWatch 认为最新版本的 apk 上的版本代码自上一版本以来没有增加。

我们最近将 Android Studio 构建工具从 25.0.0.0 升级到 26.0.0.2,问题似乎与此更改有关。

版本代码存储在文件 AndroidManifest.xml 中的 apk(这是一个 zip 文件)中。 AndroidManifest.xml 是一个二进制文件。

我需要更改什么才能强制 Android Studio 以 AirWatch 能够识别的方式将版本代码写入 apk AndroidManifest.xml?

我的应用正在使用 SDK 26 的功能,这意味着要恢复到构建工具 25.0.0.0 支持的早期版本会非常痛苦。

Android 的二进制 XML 格式支持 2 种字符串编码,UTF8 和 UTF16。

AirWatch当前版本好像只支持UTF16格式

在 Android 构建工具的早期版本中(特别是 Gradle),字符串以 UTF16 编码,因此 AirWatch 能够提取版本代码。

但是,当使用 Gradle 3.0.0 时,编码更改为 UTF8。

幸运的是,您可以通过 gradle.properties 文件 () 中的设置更改构建选项以将编码恢复为 UTF16。

# 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