Gradle, Android and the ANDROID_HOME SDK location

本文介绍了一种常见的Gradle打包APK时遇到的问题及其解决方案。问题表现为Gradle构建失败,提示SDK位置未找到。文章提供了解决该问题的具体步骤,包括在项目根目录下创建local.properties文件并设置正确的SDK路径。

使用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则此错误应该没有了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值