1.把gradle路径设为本地路径
Jenkins部署在远程linux服务器上,使用git将代码下载到服务器路径下后,无法使用gradle命令
因为默认配置都是gradle同步时 实时从网上下载,进入gradle-wrapper.properties可查看配置:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
远程服务器网速慢,gradle下载不下来
解决方案:本地下载好gradle-2.14.1-all.zip,copy到远程服务器上,在gradle-wrapper.properties文件中修改路径为本地路径:
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=file\:/jenkins/jenkins_home/workspace/uicase/gradle/wrapper/gradle-2.14.1-all.zip
2.执行./gradlew 仍错误,报错
“Error:Gradle distribution 'file\:/jenkins/jenkins_home/workspace/uicase/gradle/wrapper/gradle-2.14.1-all.zip' contains too many directories. Expected to find exactly 1 directory.”
找了很多资料,发现问题在:
gradle-2.14.1-all.zip 为我本地mac本下载后再拷到服务器上,mac的safari浏览器下载完后自动解压了,因为需要zip包所以我手动再压缩成zip包,OSX 自动生成许多__MACOSX 文件夹
解决方案:
在服务器上找到zip所在文件夹下,输入以下命令:
zip -d gradle-2.14.1-all.zip __MACOSX/*,再重新运行./gradlew,问题解决。
感谢:
3.Terminal执行./gradlew clean成功,但在jenkins脚本中执行./gradlew clean失败
报错信息:
* What went wrong:
A problem occurred configuring root project 'BloodGlucose'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
解决方案:
解决:在系统管理->系统设置 -> 全局属性 -- Environment variables里面新增一个全局环境变量,配置ANDROID_HOME即可。
感谢
4../gradlew clean成功,执行./gradlew assembleDebug 失败
①报错信息:
* What went wrong:
Execution failed for task ':uitest:mergeDebugResources'.
> Error: java.lang.RuntimeException: Crunching Cruncher drop_down_list_arrow.png failed, see logs
看到网上有个盆友说,是因为png文件不符合标准,替换即可。于是找出这个文件在哪,逐条删除。。
[root@LetvWebServer-8CB344 BasicSample]# find . -name drop_down_list_arrow.png
./uitest/build/intermediates/exploded-aar/cn.trinea.android.common/trinea-android-common/4.2.15/res/drawable-hdpi/drop_down_list_arrow.png
./uitest/build/intermediates/exploded-aar/cn.trinea.android.common/trinea-android-common/4.2.15/res/drawable-mdpi/drop_down_list_arrow.png
./uitest/build/intermediates/exploded-aar/cn.trinea.android.common/trinea-android-common/4.2.15/res/drawable-ldpi/drop_down_list_arrow.png
但是重新执行./gradlew assembleDebug仍然报错,这些图片文件在build的过程中再次生成,但又阻碍继续build。。
再次寻觅答案~~
后找到
解决方案:
在build.gradle文件中加入下面两行(标黄)即可:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
②解决完上面的问题,继续运行,仍报错
报错信息:
* What went wrong: Execution failed for task ':uitest:processDebugResources'. > com.android.ide.common.process.ProcessException: Failed to execute apt ...... Caused by: org.gradle.process.internal.ExecException: Process 'command '/data/android-sdk/r24.4.1/build-tools/23.0.1/aapt'' finished with non-zero exit value 127
这个问题貌似很多人遇到,但是解决办法试了都不管用~~~ 最后发现一个靠谱的答案 ~~ 因为确实libz.so.1文件~~
http://stackoverflow.com/questions/31868406/aapt-finished-with-non-zero-exit-value-127
但是这个答主所在服务器为ubuntu,下载包的命令在centos上并不管用,也搜寻不到相关的包。
后再次寻觅~~ 终于寻找到安装缺失包的方法~~
解决方案:
[root@Sample]# yum whatprovides libz.so.1
......
zlib-1.2.3-29.el6.i686 : The zlib compression and decompression library
Repo : CentOS-os
匹配来自于:
Other : libz.so.1
————————————————————
查找到相关包:zlib-1.2.3-29.el6.i686
[root@Sample]#sudo yum install zlib-1.2.3-29.el6.i686
安装成功后,重新./gradlew assembleDebug ~ 成功~~