I try to run android build on docker container.
My dockerfile's contents is here:
FROM openjdk:8-jre-alpine
RUN mkdir -p /myapp
WORKDIR /myapp
COPY . .
RUN apk add --update nodejs nodejs-npm
RUN apk add git
RUN apk add zip
RUN apk --no-cache add curl
I create a docker image and run it. I run below commands on docker terminal.
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip -q sdk-tools-linux-4333796.zip -d Android-sdk
export ANDROID_HOME=/path-to-sdk/Android-sdk
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
yes | sdkmanager --licenses
cd MyApplication && chmod +x gradlew && ./gradlew :app:assembledebug
MyApplication is a default empty activity project of Android Studio.
Error log is here:
/gradlew :app:assembledebug
Task :app:preBuild UP-TO-DATE Task :app:preDebugBuild UP-TO-DATE Task :app:compileDebugAidl NO-SOURCE Task :app:compileDebugRenderscript UP-TO-DATE Task :app:checkDebugManifest UP-TO-DATE Task :app:generateDebugBuildConfig UP-TO-DATE Task :app:prepareLintJar UP-TO-DATE Task :app:mainApkListPersistenceDebug UP-TO-DATE Task :app:generateDebugResValues UP-TO-DATE Task :app:generateDebugResources UP-TO-DATE Task :app:mergeDebugResources 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.3.0-alpha12-5013011-linux Daemon #0: 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
EDIT
This project works fine on my mac laptop. Local machine build is ok but it doesn't work on docker container.
EDIT
I run --stacktrace
parameter. aapt2 not found
Caused by: java.io.IOException: Cannot run program "/root/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-4818971-linux.jar/6f8af69a2b8f839763b018ee3b5c1d41/aapt2-3.2.0-4818971-linux/aapt2": error=2, No such file or directory at com.android.builder.internal.aapt.v2.Aapt2DaemonImpl.startProcess(Aapt2DaemonImpl.kt:80) at com.android.builder.internal.aapt.v2.Aapt2Daemon.checkStarted(Aapt2Daemon.kt:53) ... 8 more Caused by: java.io.IOException: error=2, No such file or directory ... 10 more