简体   繁体   中英

How to set Android target version in Qt project?

In qmake there is the possibility to define a variable VERSION which will then result in a change of the executable version number on a Windows target, which can be viewed in the properties of the executable file on Windows.

I am looking for a possibility to modify the version that is visible on Android devices in app manager in a similar way. Does Qt provide any automated way of updating this information that is usable for automated builds? The only thing I found is that Qt allows opening the AndroidManifest.xml in a special editor Window of Qt Creator, which is AFAICS not usable for automation.

QTBUG-44455 has been fixed in-between. Now it is possible to define the Android target version via qmake using ANDROID_VERSION_NAME and ANDROID_VERSION_CODE variables.

I'm using APKTool to do this.

After QtCreator generated your apk file, you can use apktool to decompile the apk (extracts it to a structure of files and folders). Then you can easily modify a yaml file present a the root of the decompiled folder with the expected version number. Later, use apktool again to recompile the apk. Finally you need to sign it and then you are done: apk is ready to be used and will show the new version you specified from Android app manager.

It's not obvious but it works well in the end. After you did it once using command lines, it's easy to automatize it (I do it from a C++ program, but Python can do this easily too).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM