4

zipalign 正在手动工作,但在 Jenkins 后期构建下失败。我在 Ubuntu Aws ec2 实例上运行它。请有人可以帮我解决这个问题。

詹金斯输出:

BUILD SUCCESSFUL

Total time: 14.421 secs
Built the following apk(s): 
    /var/lib/jenkins/workspace/PP_androidBuild/PatientPortal/platforms/android/build/outputs/apk/android-debug.apk
[PP_androidBuild] $ echo '"resolving effective environment"'
[SignApksBuilder] searching environment variable ANDROID_HOME=/opt/android-sdk-linux for zipalign...
[SignApksBuilder] found zipalign in Android SDK's latest build tools: /opt/android-sdk-linux/build-tools/23.0.1/zipalign
[SignApksBuilder] /opt/android-sdk-linux/build-tools/23.0.1/zipalign -f -p 4 /var/lib/jenkins/workspace/PP_androidBuild/PatientPortal/platforms/android/build/outputs/apk/android-debug.apk /var/lib/jenkins/workspace/PP_androidBuild/SignApksBuilder-out/zipalign/aligned-android-debug-6100835664895780913.apk
[PP_androidBuild] $ /opt/android-sdk-linux/build-tools/23.0.1/zipalign -f -p 4 /var/lib/jenkins/workspace/PP_androidBuild/PatientPortal/platforms/android/build/outputs/apk/android-debug.apk /var/lib/jenkins/workspace/PP_androidBuild/SignApksBuilder-out/zipalign/aligned-android-debug-6100835664895780913.apk
FATAL: [SignApksBuilder] zipalign failed: exit code 1
ERROR: zipalign failed on APK /var/lib/jenkins/workspace/PP_androidBuild/PatientPortal/platforms/android/build/outputs/apk/android-debug.apk: exit code 1
Finished: FAILURE

我在命令提示符下运行它时的输出:

jenkins@ip-172-31-22-20:~$  /opt/android-sdk-linux/build-tools/23.0.1/zipalign -f -p 4 /var/lib/jenkins/workspace/PP_androidBuild/PatientPortal/platforms/android/build/outputs/apk/android-debug.apk /var/lib/jenkins/workspace/PP_androidBuild/SignApksBuilder-out/zipalign/aligned-android-debug-6100835664895780913.apk
jenkins@ip-172-31-22-20:~$ ls -lthr /var/lib/jenkins/workspace/PP_androidBuild/SignApksBuilder-out/zipalign/aligned-android-debug-6100835664895780913.apk
-rw-r--r-- 1 jenkins jenkins 5.9M Sep  8 14:09 /var/lib/jenkins/workspace/PP_androidBuild/SignApksBuilder-out/zipalign/aligned-android-debug-6100835664895780913.apk

我进一步调查发现还创建了aligned-android-debug-6100835664895780913.apk:

$ ls -lthr /var/lib/jenkins/workspace/PP_androidBuild/SignApksBuilder-out/zipalign/aligned-android-debug-6100835664895780913.apk | grep aligned-android-debug-6100835664895780913.apk
-rwxrwxrwx 1 jenkins jenkins 5.9M Sep  8 14:09 /var/lib/jenkins/workspace/PP_androidBuild/SignApksBuilder-out/zipalign/aligned-android-debug-6100835664895780913.apk

那么错误是什么?如何找到它并排除故障?

FATAL: [SignApksBuilder] zipalign failed: exit code 1 
4

1 回答 1

0

问题是因为生成的密钥文件

问题

  • 我已经为发布 apk 生成了密钥文件,
  • 但我已将我的 jenkins 构建配置为在调用 gradle 部分生成调试 apk

zipalign 退出与 code1

解决方案

  • 如果您为发布 apk 生成密钥文件,则配置 jenkins 构建(如下所述)以生成签名发布 apk

摇篮配置

  • 成功配置 buid 后,您将获得已签名的发布 apk

建立成功

于 2020-08-04T10:18:00.317 回答