Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75010

Android deploy tool fails with apksigner error on macOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.0, 5.12.1, 5.12.2
    • Build tools: Other
    • None
    • macOS Mojave
      Android SDK 28.0.3
    • Android, macOS

    Description

      It looks like zipalign utility (called from within androiddeployqt tool) does not flush it's write buffers on time, thus apksigner starts reading broken APK and throws different ZIP file format errors. Here are a few examples: 

      :packageRelease
      :assembleRelease
      
      
      BUILD SUCCESSFUL in 12s
      29 actionable tasks: 9 executed, 20 up-to-date
      Exception in thread "main" com.android.apksig.apk.ApkFormatException: Malformed ZIP Central Directory record #1 at file offset 32818355
      	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: 0x89768169
      	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.
        -- Run with --verbose for more information.

      or (happening in QtCreator):

      :packageRelease
      :assembleRelease
      
      BUILD SUCCESSFUL in 11s
      29 actionable tasks: 6 executed, 23 up-to-date
      Exception in thread "main" com.android.apksig.apk.ApkFormatException: Malformed ZIP Central Directory record #1 at file offset 32826934
      	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: 0x24a93c14
      	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.
        -- Run with --verbose for more information.
      11:30:12: The process "/Users/gusc/Qt/5.12.0/android_armv7/bin/androiddeployqt" exited with code 15.
      Error while building/deploying project TrueFiApplication (kit: Android for armeabi-v7a (Clang Qt 5.12.0 for Android ARMv73))
      When executing step "Build Android APK"
      

      A workaround for now is to call zipalign and apksigner manually after running androiddeployqt and placing a few second sleep call in-between.  I used the same commands used in signPackage function.

      This problem has been only seen on macOS Mojave. Does not happen on Windows 10.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            gusc Gusts Kaksis
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes