环境:
mac,编译android报错
> Configure project :
Checking the license for package Android SDK Build-Tools 25.0.2 in /Volumes/B/android/android-sdk-macosx/licenses
Warning: License for package Android SDK Build-Tools 25.0.2 not accepted.
Checking the license for package Android SDK Platform 25 in /Volumes/B/android/android-sdk-macosx/licenses
Warning: License for package Android SDK Platform 25 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'mydemo'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 25.0.2, Android SDK Platform 25].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
这是一个关于License的报错,尝试过的方法有:
1. 使用android studio删除sdk重新下载;
2.在~/Library/Android/sdk目录下,删除原来的License目录重新生成,生成方法见第3点;
3.~/Library/Android/sdk/tools/bin下,使用命令:./sdkmanager --licenses,一路按y
试过以上方法还是报错,最后好好分析错误打印:
Checking the license for package Android SDK Build-Tools 25.0.2 in /Volumes/B/android/android-sdk-macosx/licenses
Warning: License for package Android SDK Build-Tools 25.0.2 not accepted.
应该是工程设置sdk路径有点混乱,在/Volumes/B/android/android-sdk-macosx下没有license文件夹,于是把~/Library/Android/sdk下的licenses文件夹copy过去,完美解决:
cp -rf ~/Library/Android/sdk/licenses /Volumes/B/android/android-sdk-macosx/