jenkins 构建 Android应用时出现类似“The SDK directory '/root/android-sdk-linux' does not exist.”的解决方案

最近在尝试Android+jenkins+github+linux服务器版集成环境搭建。在按照教程一步步配置后,在打包的地方出现了这个问题:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/root/android-sdk-linux' does not exist.

* 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

构建由于SDK路径的问题失败了。但是我在linux上检查了一下路径,发现路径在我的环境里的确是/root/android-sdk-linux。经过Google,我发现问题出在权限上。我的SDK目录处于Root的根目录,通常情况下,unix权限不允许其他用户(指jenkins)进入这个目录。我们可以把我们的SDK目录切换到其他位置(非根目录)。

例如我执行了移动文件夹的命令:

 mv root/android-sdk-linux opt/

把android-sdk-linux文件夹移动到了opt/路径。同样的,这个时候不要忘了修改环境变量:
先执行:

vim /etc/profile

然后修改相应行:

export ANDROID_HOME="/opt/android-sdk-linux"

最后保存文件退出后执行:

source /etc/profile

这个时候我们在构建一次,发现这次错误消失了,构建成功了。

BUILD SUCCESSFUL in 3m 19s
146 actionable tasks: 140 executed, 6 up-to-date
Build step 'Invoke Gradle script' changed build result to SUCCESS
Archiving artifacts
Email was triggered for: Always
Sending email for trigger: Always
Finished: SUCCESS

在jenkins部署过程中还是出现了几个坑,但是过程中也让我学到了很多新东西~

https://groups.google.com/forum/#!topic/jenkinsci-users/zr_pqCPfVL4

猜你喜欢

转载自blog.csdn.net/y505772146/article/details/78643583