Signature problem (Android)



  • Hello,

    I created an app in Android Studio and signed it. All are worked well.

    When I tried to signing another app created by Qt Creator I got the error. A key was generated by Qt Creator.

    Unable to open '/Users/artemyerko/ApkProjects/build-Updater-Android_for_armeabi_v7a_Clang_Qt_5_12_4_for_Android_ARMv75-Release/android-build//build/outputs/apk/release/android-build-release-unsigned.apk' as zip archive
    zipalign command failed.
    16:58:55: The process "/Users/artemyerko/Qt/5.12.4/android_armv7/bin/androiddeployqt" exited with code 15.
    Error while building/deploying project Updater (kit: Android for armeabi-v7a (Clang Qt 5.12.4 for Android ARMv75))
    When executing step "Build Android APK"
    

    In build dir I got next:

    0_1562248828358_Screen Shot 2019-07-04 at 4.59.49 PM.png

    I decided to move the file "android-build-release-unsigned.ap" in to release dir, but I got the next:

    Signed
    	at com.android.apksig.internal.apk.v1.V1SchemeVerifier.parseZipCentralDirectory(V1SchemeVerifier.java:1782)
    	at com.android.apksig.ApkVerifier.getAndroidManifestFromApk(ApkVerifier.java:429)
    	at com.android.apksig.ApkVerifier.verify(ApkVerifier.java:176)
    	at com.android.apksig.ApkVerifier.verify(ApkVerifier.java:125)
    	at com.android.apksigner.ApkSignerTool.verify(ApkSignerTool.java:466)
    	at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:112)
    Caused by: com.android.apksig.zip.ZipFormatException: Not a Central Directory record. Signature: 0xb1527eca
    	at com.android.apksig.internal.zip.CentralDirectoryRecord.getRecord(CentralDirectoryRecord.java:143)
    	at com.android.apksig.internal.apk.v1.V1SchemeVerifier.parseZipCentralDirectory(V1SchemeVerifier.java:1780)
    	... 5 more
    apksigner command failed.
    16:11:03: The process "/Users/artemyerko/Qt/5.12.4/android_armv7/bin/androiddeployqt" exited with code 15.
    Error while building/deploying project Updater (kit: Android for armeabi-v7a (Clang Qt 5.12.4 for Android ARMv75))
    When executing step "Build Android APK"
    16:11:03: Elapsed time: 00:12.
    

    After this error I tried to use a key created by Android Studio, disable signing by Qt Creator and add to "build.gradle" file next:

    apply plugin: 'com.android.application'
    
    def keystorePropertiesFile = rootProject.file("keystore.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    
    buildscript {
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.0'
        }
    }
    
    repositories {
        google()
        jcenter()
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha01'
    
        implementation 'androidx.work:work-runtime:2.1.0-beta01'                               //$rootProject.workVersion"
        implementation 'androidx.concurrent:concurrent-futures:1.0.0-beta01'                   //$rootProject.futuresVersion"
        implementation 'androidx.concurrent:concurrent-listenablefuture:1.0.0-beta01'          //$rootProject.futuresVersion"
        implementation 'androidx.concurrent:concurrent-listenablefuture-callback:1.0.0-beta01' //$rootProject.futuresVersion"
    }
    
    android {
        /*******************************************************
         * The following variables:
         * - androidBuildToolsVersion,
         * - androidCompileSdkVersion
         * - qt5AndroidDir - holds the path to qt android files
         *                   needed to build any Qt application
         *                   on Android.
         *
         * are defined in gradle.properties file. This file is
         * updated by QtCreator and androiddeployqt tools.
         * Changing them manually might break the compilation!
         *******************************************************/
    
        compileSdkVersion androidCompileSdkVersion.toInteger()
    
        buildToolsVersion androidBuildToolsVersion
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
                aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
                res.srcDirs = [qt5AndroidDir + '/res', 'res']
                resources.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                assets.srcDirs = ['assets']
                jniLibs.srcDirs = ['libs']
           }
        }
    
        applicationVariants.all { variant ->
           variant.outputs.all {
               outputFileName = "../" + outputFileName
           }
        }
    
        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAliasRelease']
                keyPassword keystoreProperties['keyPasswordRelease']
                storeFile file(keystoreProperties['storeFileRelease'])
                storePassword keystoreProperties['storePasswordRelease']
            }
            debug {
                keyAlias keystoreProperties['keyAliasDebug']
                keyPassword keystoreProperties['keyPasswordDebug']
                storeFile file(keystoreProperties['storeFileDebug'])
                storePassword keystoreProperties['storePasswordDebug']
            }
        }
        buildTypes {
            release {
                debuggable false  
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.release
                ext.alwaysUpdateBuildId = true
            }
            debug {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.debug
                ext.alwaysUpdateBuildId = true
            }
        }
    
        lintOptions {
            abortOnError false
        }
    }
    
    

    In build directory I got:

    0_1562249997781_Screen Shot 2019-07-04 at 5.19.14 PM.png

    I decided to move the file "android-build-release-unsigned.apk" to debug folder too and run again and apk was installed on device, but the apk wasn't signed.

    Than I remove from "build.gradle" next parts:

    def keystorePropertiesFile = rootProject.file("keystore.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    ...
    signingConfigs {
    ...
    }
    buildTypes {
    ...
    }
    

    and enable signing by QtCreator only with Android Studio generated key, run build

    0_1562250669345_Screen Shot 2019-07-04 at 5.30.53 PM.png

    In build folder I got:

    0_1562250748510_Screen Shot 2019-07-04 at 5.32.04 PM.png

    and error:

    Unable to open '/Users/artemyerko/ApkProjects/build-Updater-Android_for_armeabi_v7a_Clang_Qt_5_12_4_for_Android_ARMv75-Release/android-build//build/outputs/apk/release/android-build-release-unsigned.apk' as zip archive
    zipalign command failed.
    17:34:28: The process "/Users/artemyerko/Qt/5.12.4/android_armv7/bin/androiddeployqt" exited with code 15.
    Error while building/deploying project Updater (kit: Android for armeabi-v7a (Clang Qt 5.12.4 for Android ARMv75))
    When executing step "Build Android APK"
    

    I decided to move the file "android-build-release-unsigned.apk" to release folder too, run build again and got:

    Signed
    	at com.android.apksig.internal.apk.v1.V1SchemeVerifier.parseZipCentralDirectory(V1SchemeVerifier.java:1782)
    	at com.android.apksig.ApkVerifier.getAndroidManifestFromApk(ApkVerifier.java:429)
    	at com.android.apksig.ApkVerifier.verify(ApkVerifier.java:176)
    	at com.android.apksig.ApkVerifier.verify(ApkVerifier.java:125)
    	at com.android.apksigner.ApkSignerTool.verify(ApkSignerTool.java:466)
    	at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:112)
    Caused by: com.android.apksig.zip.ZipFormatException: Not a Central Directory record. Signature: 0xdb698620
    	at com.android.apksig.internal.zip.CentralDirectoryRecord.getRecord(CentralDirectoryRecord.java:143)
    	at com.android.apksig.internal.apk.v1.V1SchemeVerifier.parseZipCentralDirectory(V1SchemeVerifier.java:1780)
    	... 5 more
    apksigner command failed.
    17:35:23: The process "/Users/artemyerko/Qt/5.12.4/android_armv7/bin/androiddeployqt" exited with code 15.
    Error while building/deploying project Updater (kit: Android for armeabi-v7a (Clang Qt 5.12.4 for Android ARMv75))
    When executing step "Build Android APK"
    17:35:23: Elapsed time: 00:12.
    

    and in build folder I got:

    0_1562250997282_Screen Shot 2019-07-04 at 5.36.26 PM.png

    But the signed apk wasn't worked like apk signed by Android Studion.

    Qt 5.12.4
    SDK Version: 26.1.1
    NDK Version: 20.0.5594570
    build-tools 28.0.3
    JDK: jdk1.8.0_201
    OS: macOS

    How to signing Qt Android apk in release version?

    Source

    This doesn't help me(


Log in to reply