Qt 5.12.6 Android: How to change zipalign apk name

334 Views Asked by At

I changed my application apk name from build.gradle (gradle version 4.6) with these lines of code:

android.applicationVariants.all { variant ->
    variant.outputs.all {
        outputFileName = "App.apk"
    }
}

But if i build the apk in release mode and i sign it, zipalign fails with this error:

Unable to open /home/user/Projects/App/build/App/Android_for_armeabi_v7a_Clang_Qt_5_12_6_for_Android_ARMv7/Release/android-build/build/outputs/apk/release/android-build-release-unsigned.apk as zip archive. zipalign command failed.

The process /home/user/Qt/5.12.6/5.12.6/android_armv7/bin/androiddeployqt exited with code 15.

If I leave the apk name unchanged, everything works fine.

How can I change the name zipalign searches for?

1

There are 1 best solutions below

1
Kareem Alsaifi On
android.applicationVariants.all { variant ->
    if(variant.zipAlign) {
        def file = variant.outputFile
        def fileName = file.name.replace(".apk", "CHANGE_ME" + ".apk")
        variant.outputFile = new File(file.parent, fileName)
    }
}