我正在尝试在CI服务器上的Docker容器中构建Android应用程序,并且AAPT2无法合并资源。
基本Docker图像是openjdk:8-alpine
从高山存储库中安装在我的图像中的软件包是:
build-base alpine-sdk bash ca-certificates curl gcc git gzip musl-dev openssh-client python python-dev tar unzip wget
也我正在下载并从
下载和安装glibchttps://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk
安装的Android SDK软件包是
build-tools;26.0.0-rc2 platforms;android-25 platform-tools extras;android;m2repository extras;google;m2repository extras;google;google_play_services
该应用程序当前使用Gradle Wrapper 4.0-rc-1
错误是:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.lang.ExceptionInInitializerError
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:242)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:303)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:295)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:177)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:235)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:224)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:121)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:77)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:102)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:96)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:611)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:566)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:96)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: com.android.build.gradle.tasks.ResourceException: Error: java.lang.ExceptionInInitializerError
at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:201)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:80)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:168)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:303)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:295)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:177)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: Error: java.lang.ExceptionInInitializerError
at com.android.ide.common.res2.MergedResourceWriter.postWriteAction(MergedResourceWriter.java:596)
at com.android.ide.common.res2.MergeWriter.end(MergeWriter.java:45)
at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:237)
at com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:301)
at com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:412)
at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:194)
... 39 more
Caused by: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
at com.android.ide.common.res2.MergedResourceWriter.postWriteAction(MergedResourceWriter.java:564)
... 44 more
Caused by: java.lang.ExceptionInInitializerError
... 45 more
Caused by: java.lang.ExceptionInInitializerError
at com.android.builder.internal.aapt.v2.AaptV2Jni.lambda$compile$0(AaptV2Jni.java:90)
Caused by: com.android.tools.aapt2.Aapt2Exception: Failed to load shared library '/tmp/aapt2_8990614974494423638.dir/libc++.so'
at com.android.tools.aapt2.Aapt2Jni.loadLibraryFromResource(Aapt2Jni.java:162)
at com.android.tools.aapt2.Aapt2Jni.loadSharedLibrariesFromResources(Aapt2Jni.java:204)
at com.android.tools.aapt2.Aapt2Jni.load(Aapt2Jni.java:97)
at com.android.tools.aapt2.Aapt2Jni.<clinit>(Aapt2Jni.java:43)
... 1 more
Caused by: java.lang.UnsatisfiedLinkError: /tmp/aapt2_8990614974494423638.dir/libc++.so: Error relocating /tmp/aapt2_8990614974494423638.dir/libc++.so: strtoll_l: symbol not found
at com.android.tools.aapt2.Aapt2Jni.loadLibraryFromResource(Aapt2Jni.java:159)
... 4 more
BUILD FAILED in 30s
我尝试安装不同的高山软件包而没有运气。我感觉这与glibc和/或musl库有关,但我不太了解它不知道如何解决这个问题
另外,所有内容在非常相似的图像(也基于高山(上效果很好,构建工具25.0.3和Gradle 3.5。
。有线索吗?谢谢
我偶然发现了相同的错误。您怀疑的问题是Alpine Linux用MUSL而不是GNU LIBC船舶,Android SDK工具需要GLIBC。
您可以使用类似的东西:https://github.com/frol/docker-alpine-glibc,或者,如果您适合您的其他人为您编译Glibc,请自己创建类似的图像。
您可以检查缺少哪些库(Enoent Singal(使用:$ strace ./aapt2
然后尝试将这些库的imbolic链接与预期路径创建。