我目前正在致力于自动化 APK 构建过程,为该项目设置 Jenkins 管道。我的 Jenkins 位于安装了 npm、Ionic、OpenJDK、Android SDK 和 Gradle 的 Docker 容器上。 我们的团队正在项目中使用电容器。这是我管道中的“构建 APK”阶段
stage('Build APK') {
sh 'npm run build'
sh 'npx capacitor sync android'
sh 'npx capacitor build android --keystorepath /keyfiles/<filename>.jks --keystorealias <alias> --keystorepass <pass> --keystorealiaspass <pass> --androidreleasetype APK'
但是,我在 Jenkins 控制台中遇到错误:
> Task :app:mergeReleaseResources FAILED
> Task :capacitor-google-maps:extractReleaseAnnotations
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-7.2.1-7984345-linux Daemon #0: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-7.2.1-7984345-linux Daemon #2: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-7.2.1-7984345-linux Daemon #1: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
尝试在google和stackoverflow上搜索,但仍然存在问题。
我通过切换到 Jenkins 的不同基本映像解决了这个问题。我一开始用的是Alpine镜像(
FROM docker.io/jenkins/jenkins:alpine
),后来改成了最新版本(FROM jenkins/jenkins:latest
),成功解决了问题。