问题描述
使用gradle编译Android程序,报如下错误:
Starting a Gradle Daemon (subsequent builds will be faster) Build-tool
32.0.0 is missing DX at /usr/local/android-sdk/build-tools/32.0.0/dx File /root/.android/repositories.cfg could not be loaded. Build-tool
32.0.0 is missing DX at /usr/local/android-sdk/build-tools/32.0.0/dxFAILURE: Build failed with an exception.
- What went wrong: Could not determine the dependencies of task ‘:app:compileReleaseJavaWithJavac’.
Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager.
解决方法
- 使用SDK Manager安装 BuildTools, 先到https://developer.android.google.cn/studio 下载commandlinetools:
- 解压该工具到ANDROID_HOME目录下,然后:
cd cmdline-tools
mkdir latest
mv bin lib NOTICE.txt source.properties latest
- 再执行安装:
cd bin
./sdkmanager --list --channel=0|grep build-tool
./sdkmanager "build-tools;32.0.0" "platforms;android-32"
- 安装完成后,进行构建,会报如下错误:
Build-tool
32.0.0 is missing DX at /usr/local/android-sdk/build-tools/32.0.0/dx File /root/.android/repositories.cfg could not be loaded. Build-tool
32.0.0 is missing DX at /usr/local/android-sdk/build-tools/32.0.0/dx
- 进入$ANDROID_HOME/build-tools/32.0.0,执行如下命令:
mv d8 dx \
&& cd lib \
&& mv d8.jar dx.jar
6.重新构建,问题解决。
记之。