AAPT2无法合并Docker上的资源

时间:2017-06-03 13:53:19

标签: android docker aapt alpine

我试图在CI服务器上的docker容器中构建一个Android应用程序,而aapt2无法合并资源。

Base Docker Image是openjdk:8-alpine

我在alpine存储库的图像中安装的软件包是:

build-base alpine-sdk bash ca-certificates curl gcc git gzip musl-dev openssh-client python python-dev tar unzip wget

我也从

下载并安装Glibc
https://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的图像)上一切正常。

任何线索?感谢

2 个答案:

答案 0 :(得分:1)

我偶然发现了同样的错误。您怀疑的问题是Alpine Linux附带Musl而不是GNU libc,Android SDK工具需要glibc。

您可以使用以下内容:https://github.com/frol/docker-alpine-glibc,或者如果您对其他人为您编译glibc感到满意,则可以自行创建类似的图像。

答案 1 :(得分:0)

您可以使用$ strace ./aapt2检查缺少的库(ENOENT单个) 然后尝试创建这些库到预期路径的符号链接。