我使用的是Dynatrace Android Agent。作为插装的一部分,它需要使用ApkSigner.jar对.apk进行签名。在我将Android Gradle Plugin从4.0.1更新到4.1.0之后,签名过程开始失败,有以下例外:
line 134: 51916 Segmentation fault: 11 "${TOOLS_OS}/zipalign" -p -f 4
"${INSTRUMENTED_APK}" "${ZIPALIGNED_APK}"
Zipaligning completed - Instrumented and zipaligned APK:
dynatrace/../app/build/outputs/apk/release/app-release/dist/app-
release-zipaligned.apk
Signing non-release APK ...
Exception in thread "main" java.io.IOException: Failed to deduce Min API Level from APK's AndroidManifest.xml. Use --min-sdk-version to override.
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:215)
at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:93)
Caused by: java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:169)
at com.android.apksigner.ApkSignerTool.getMinSdkVersionFromAndroidManifest(ApkSignerTool.java:779)
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:213)
... 1 more
回滚AGP版本后问题立即消失。
是什么导致签名失败?如何在不使用--min-sdk-version
参数的情况下修复它?
听起来很像Dynatrace论坛上的这个问题。请检查先决条件并按照本指南迁移到Dynatrace Android Gradle插件版本8.x