Android Aapt2InternalException in compilation

删除回忆录丶 提交于 2019-12-13 04:44:37

问题


Android sdk installation steps:

wget -q https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -O android-sdk-tools.zip \
 && unzip -q android-sdk-tools.zip -d ${ANDROID_HOME} \
 && rm android-sdk-tools.zip
yes | sdkmanager --licenses
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools

Clone an android project from github. clean task works fine.

$git clone and-repo-url
$cd and-repo && ./gradlew clean

There is no platform and build-tools yet.

$ls /opt/android-sdk-linux
licenses  tools

Building apk is failed:

$./gradlew  :app:assembleDebug 

This task installs build-tools and platforms

$ls /opt/android-sdk-linux
build-tools     licenses        platform-tools  platforms       tools

$ls /opt/android-sdk-linux/build-tools/28.0.2/
NOTICE.txt                  arm-linux-androideabi-ld    i686-linux-android-ld       mainDexClassesNoAapt.rules  split-select
aapt                        bcc_compat                  lib                         mipsel-linux-android-ld     x86_64-linux-android-ld
aapt2                       core-lambda-stubs.jar       lib64                       package.xml                 zipalign
aarch64-linux-android-ld    d8                          llvm-rs-cc                  renderscript
aidl                        dexdump                     mainDexClasses              runtime.properties
apksigner                   dx                          mainDexClasses.rules        source.properties

Error message is here:

  • 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-4818971-linux Daemon #0: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does.

回答1:


I had installed android sdk on linux machine by following steps. Download android sdk from link 'https://developer.android.com/studio' from section 'Command line tools only'.

sdkmanager is located in android_sdk/tools/bin/. use sdkmanager to download other packages. create a package name 'SDK_26'

sdkmanager "build-tools;26.0.3"
sdkmanager "platforms;android-26"
sdkmanager "platform-tools"
sdkmanager "ndk-bundle"

[download linux 64-bit ndk from location 'https://developer.android.com/ndk/downloads/' and rename it to 'ndk-bundle'

And compile the app as

export ANDROID_HOME=/home/desktop/android/SDK_26
export JAVA_HOME=/sw/licensed/sun/jdk/1.8.0_91
export PATH=$JAVA_HOME/bin:$PATH
chmod 777 gradlew
./gradlew
./gradlew assembleRelease


来源:https://stackoverflow.com/questions/56414504/android-aapt2internalexception-in-compilation

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