我正在使用 Dynatrace Android 代理。作为检测的一部分,它需要使用 ApkSigner.jar 对 .apk 进行签名。在我将 Android Gradle 插件从 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
参数的情况下修复它?