Error on Android build: “aapt2: error=2, No such file or directory”

我只是一个虾纸丫 提交于 2020-01-06 05:31:54

问题


Getting the following error on a build server.

Download https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.0-beta05-4818971/aapt2-3.2.0-beta05-4818971-linux.jar

...

Caused by: java.io.IOException: Cannot run program "/root/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-beta05-4818971-linux.jar/43bd0f91870a1f4f8e99e05eefb192e9/aapt2-3.2.0-beta05-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

Full build log

Looking at the jar downloaded, it appears that the file it's looking for is at the root of the jar file. Not sure why it's trying to find it in 43bd0f91870a1f4f8e99e05eefb192e9/aapt2-3.2.0-beta05-4818971-linux/

Versions used:

gradle-4.8-all.zip
classpath 'com.android.tools.build:gradle:3.2.0-beta05'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51"

compileSdkVersion 28
buildToolsVersion '28.0.2'
minSdkVersion 23
targetSdkVersion 28

回答1:


To get aapt working (this fixed my issues with the avd as well) just run these two commands:

sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1

It Should Work!!




回答2:


In my particular case it was on an alpine linux distro which made the installations a bit trickier.

Basically need to install this: https://github.com/sgerrand/alpine-pkg-glibc

Docker Code:

RUN echo "Installing standard dependencies..." \
  && apk add --no-cache --update --virtual=.build-dependencies \
    ca-certificates \
    wget \
  # ---------------------------------------------
  && echo "Installing glibc..." \
  && wget https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -O /etc/apk/keys/sgerrand.rsa.pub \
  && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk -O /tmp/glibc.apk \
  && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk -O /tmp/glibc-bin.apk \
  && apk add --no-cache /tmp/glibc.apk /tmp/glibc-bin.apk


来源:https://stackoverflow.com/questions/51914246/error-on-android-build-aapt2-error-2-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!