2

我最近为在 Ubuntu 16.04 上运行的 Android 项目设置了一个 Jenkins 构建服务器。我已经让它主要工作到它将从 GitHub 中提取并尝试构建一个项目的地方。出于某种原因,每当我设置要运行的任务时gradlew buildgradlew assembleDebug它总是会失败并出现一些 AAPT2 错误。我说一些是因为一个项目给我的 AAPT2 错误与另一个项目不同。这两个项目在我的本地 Windows 机器上编译都没有问题。

Jenkins 指向位于 Jenkins 机器上 /opt/android-sdk 的最新 sdk 工具 ( https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip )。Jenkins 机器配置了 oracle-java-8。

项目 1 的控制台输出:

[Gradle] - Launching build.
[Test] $ /var/lib/jenkins/workspace/Test/gradlew clean assembleDebug
Starting a Gradle Daemon (subsequent builds will be faster)
File /var/lib/jenkins/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 27.0.3 in /opt/android-sdk/licenses
License for package Android SDK Build-Tools 27.0.3 accepted.
Preparing "Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)".
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" ready.
Installing Android SDK Build-Tools 27.0.3 in /opt/android-sdk/build-tools/27.0.3
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" complete.
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" finished.
Checking the license for package Android SDK Platform 27 in /opt/android-sdk/licenses
License for package Android SDK Platform 27 accepted.
Preparing "Install Android SDK Platform 27 (revision: 3)".
"Install Android SDK Platform 27 (revision: 3)" ready.
Installing Android SDK Platform 27 in /opt/android-sdk/platforms/android-27
"Install Android SDK Platform 27 (revision: 3)" complete.
"Install Android SDK Platform 27 (revision: 3)" finished.
Checking the license for package Android SDK Platform-Tools in /opt/android-sdk/licenses
License for package Android SDK Platform-Tools accepted.
Preparing "Install Android SDK Platform-Tools (revision: 28.0.0)".
"Install Android SDK Platform-Tools (revision: 28.0.0)" ready.
Installing Android SDK Platform-Tools in /opt/android-sdk/platform-tools
"Install Android SDK Platform-Tools (revision: 28.0.0)" complete.
"Install Android SDK Platform-Tools (revision: 28.0.0)" finished.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:checkDebugManifest
:app:generateDebugBuildConfig
:app:mainApkListPersistenceDebug
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResourcesAAPT err(Facade for 27706406): /opt/android-sdk/build-tools/27.0.3/aapt2: 1: /opt/android-sdk/build-tools/27.0.3/aapt2: Syntax error: "(" unexpected
AAPT err(Facade for 26922534): /opt/android-sdk/build-tools/27.0.3/aapt2: 1: /opt/android-sdk/build-tools/27.0.3/aapt2: Syntax error: "(" unexpected
AAPT err(Facade for 32626108): /opt/android-sdk/build-tools/27.0.3/aapt2: 1: /opt/android-sdk/build-tools/27.0.3/aapt2: Syntax error: "(" unexpected
AAPT err(Facade for 26996178): /opt/android-sdk/build-tools/27.0.3/aapt2: 1: /opt/android-sdk/build-tools/27.0.3/aapt2: Syntax error: "(" unexpected
Slave 32626108 failed to start
java.lang.RuntimeException: AAPT slave failed to start. Please make sure the current build tools (located at /opt/android-sdk/build-tools/27.0.3/aapt2) are not corrupted.
    at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:193)
    at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:250)
    at java.lang.Thread.run(Thread.java:748)
Slave 26922534 failed to start
java.lang.RuntimeException: AAPT slave failed to start. Please make sure the current build tools (located at /opt/android-sdk/build-tools/27.0.3/aapt2) are not corrupted.
    at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:193)
    at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:250)
    at java.lang.Thread.run(Thread.java:748)
Slave 27706406 failed to start
java.lang.RuntimeException: AAPT slave failed to start. Please make sure the current build tools (located at /opt/android-sdk/build-tools/27.0.3/aapt2) are not corrupted.
    at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:193)
    at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:250)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "queued-resource-processor_1" java.util.MissingFormatArgumentException: Format specifier '%1$s'
Slave 26996178 failed to start
java.lang.RuntimeException: AAPT slave failed to start. Please make sure the current build tools (located at /opt/android-sdk/build-tools/27.0.3/aapt2) are not corrupted.
    at com.android.builder.png.AaptProcess.waitForReadyOrFail(AaptProcess.java:193)
    at com.android.builder.internal.aapt.AaptQueueThreadContext.creation(AaptQueueThreadContext.java:56)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:250)
    at java.lang.Thread.run(Thread.java:748)
    at java.util.Formatter.format(Formatter.java:2525)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2940)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.shouldDowngrade(AaptGradleFactory.java:156)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.error(AaptGradleFactory.java:122)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:253)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "queued-resource-processor_4" java.util.MissingFormatArgumentException: Format specifier '%1$s'
    at java.util.Formatter.format(Formatter.java:2525)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2940)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.shouldDowngrade(AaptGradleFactory.java:156)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.error(AaptGradleFactory.java:122)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:253)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "queued-resource-processor_3" java.util.MissingFormatArgumentException: Format specifier '%1$s'
    at java.util.Formatter.format(Formatter.java:2525)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2940)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.shouldDowngrade(AaptGradleFactory.java:156)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.error(AaptGradleFactory.java:122)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:253)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "queued-resource-processor_2" java.util.MissingFormatArgumentException: Format specifier '%1$s'
    at java.util.Formatter.format(Formatter.java:2525)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2940)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.shouldDowngrade(AaptGradleFactory.java:156)
    at com.android.build.gradle.internal.aapt.AaptGradleFactory$FilteringLogger.error(AaptGradleFactory.java:122)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:253)
    at java.lang.Thread.run(Thread.java:748)

Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: No server to serve request. Check logs for details.
:app:createDebugCompatibleScreenManifests
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug
:app:prepareLintJar UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:mergeDebugJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:processDebugJavaRes NO-SOURCE
:app:validateSigningDebug
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: No server to serve request. Check logs for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4m 33s
20 actionable tasks: 19 executed, 1 up-to-date
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE

项目 2 的控制台输出:

[Gradle] - Launching build.
[ProjectName] $ /var/lib/jenkins/workspace/ProjectName/gradlew clean assembleDebug
Starting a Gradle Daemon (subsequent builds will be faster)
File /var/lib/jenkins/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Platform 28 in /opt/android-sdk/licenses
License for package Android SDK Platform 28 accepted.
Preparing "Install Android SDK Platform 28 (revision: 4)".
"Install Android SDK Platform 28 (revision: 4)" ready.
Installing Android SDK Platform 28 in /opt/android-sdk/platforms/android-28
"Install Android SDK Platform 28 (revision: 4)" complete.
"Install Android SDK Platform 28 (revision: 4)" finished.
:clean UP-TO-DATE
:app:clean
:app:checkDebugClasspath
:app:preBuild UP-TO-DATE
:app:preDebugBuild
:app:compileDebugAidl NO-SOURCE
:app:compileDebugRenderscript
:app:checkDebugManifest
:app:generateDebugBuildConfig
:app:generateSafeArgsDebug
:app:prepareLintJar
:app:mainApkListPersistenceDebug
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResourcesAAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #2: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #0: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #1: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #4: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #3: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #5: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #7: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #6: Unexpected error output: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: 19: /var/lib/jenkins/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta03-4818971-linux.jar/af6f6047a6877ad6fb27278423eb186d/aapt2-3.2.0-beta03-4818971-linux/aapt2: Syntax error: word unexpected (expecting ")")
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.2.0-beta03-4818971-linux Daemon #2: Daemon startup failed
  This should not happen under normal circumstances, please file an issue if it does.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 27s
12 actionable tasks: 11 executed, 1 up-to-date
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure

我真的不知道为什么我会得到这些结果,尤其是这两个项目都在我的本地 Windows 机器上构建得很好。也许我错过了应该在 Jenkins 机器上安装的东西?我希望除了在 gradle.properties 中禁用 aapt2 之外还有一个答案,因为它在这里并没有真正找到问题。

4

0 回答 0