1

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?

Fausto01
  • 171
  • 14

1 Answers1

-1
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)
    }
}
Kareem Alsaifi
  • 399
  • 4
  • 11
  • While this code snippet may be the solution, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-‌​code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Twenty Mar 02 '20 at 16:14