使用gradle打包项目为apk时,遇到类似于stackoverflow上的这个问题
we have this project with several modules that is already configured and executes correctly on another developer PC using a wrapper. I cloned the complete git submodules into my machine.
Below it’s a directly print of my command line:
$ ./gradlew
FAILURE: Build failed with an exception.
* Where:
Build file '/home/budius/project_name/ActionBar-PullToRefresh/library/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':ActionBar-PullToRefresh:library'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 6.378 secs
$ echo $ANDROID_HOME
/home/budius/Applications/android-studio/sdk
$
解决方法:
I already created a local.properties file with sdk.dir= on the project root and it works. But that makes the code harder to port across systems n build server, so the question is still open.
在你的项目工程根目录下新建 local.properties文件,写上你的sdk路径:
sdk.dir=D\:\\AndroidSDK\\android-sdk
再次gradlew clean则此错误应该没有了。