热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

JenkinsBuildAndroidAPK手顺以及遇到问题的解决方案

 InstallGradleStep1:downloadhttps:services.gradle.orgdistributionsStep2:selectversion grad
 

《Jenkins Build Android APK手顺以及遇到问题的解决方案》

Install Gradle

Step 1: download

https://services.gradle.org/distributions/

Step 2: select version 

gradle-3.3-bin.zip

Step 3: upload and unzip

### login Jenkins server

bash-4.1$ cd /var/lib/jenkins

bash-4.1$ scp xxx@xxx:/home/xxx/gradle-3.3-bin.zip .

bash-4.1$ unzip gradle-3.3-bin.zip

Step 4: Jenkins config

Jenkins → manage → Global Tool Configuration → Gradle setting as following:

name : gradle3.3

GRADLE_HOME : /var/lib/jenkins/gradle-3.3

《Jenkins Build Android APK手顺以及遇到问题的解决方案》

Create Jenkins Build Job

Run Build Job

Error 1: jcenter.bintray.com:443 connection time out

* What went wrong:

A problem occurred configuring root project ‘social-depot-mobile-app-release-build’. > Could not resolve all dependencies for configuration ‘:classpath’. > Could not resolve com.android.tools.build:gradle:2.3.0. Required by: project : > Could not resolve com.android.tools.build:gradle:2.3.0. > Could not get resource ‘https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.0/gradle-2.3.0.pom’. > Could not GET ‘https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.0/gradle-2.3.0.pom’. > Connect to repo1.maven.org:443 [repo1.maven.org/151.101.52.209] failed: Connection timed out (Connection timed out) > Could not resolve com.android.tools.build:gradle:2.3.0. > Could not get resource ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.3.0/gradle-2.3.0.pom’. > Could not GET ‘https://jcenter.bintray.com/com/android/tools/build/gradle/2.3.0/gradle-2.3.0.pom’. > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection timed out (Connection timed out) * Try: Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. BUILD FAILED

Error 1 Solution:

Setting proxy for gradle on Jenkins server

bash-4.1$ cd /var/lib/jenkins/.gradle

bash-4.1$ touch gradle.properties

bash-4.1$ vi gradle.properties

systemProp.http.proxyHost=xxxx

systemProp.http.proxyPort=xxxx

systemProp.https.proxyHost=xxxx

systemProp.https.proxyPort=xxxx

gradle.properties (END)

— save

Error 2: SDK not found 

* What went wrong:

A problem occurred configuring project ‘:app’.> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

Error 2 Solution:

Install SDK on Jenkins server

Step 1: download

https://developer.android.com/studio/index.html

Step 2: select version 

sdk-tools-linux-3859397.zip

Step 3: upload and unzip

### login jenkins server

bash-4.1$ cd /var/lib/jenkins

bash-4.1$ mkdir android-sdk

bash-4.1$ cd android-sdk

bash-4.1$ scp xxxx@xxxx:/home/xxxx/sdk-tools-linux-3859397.zip .

bash-4.1$ unzip sdk-tools-linux-3859397.zip

bash-4.1$ ls -l

drwxr-xr-x 6 jenkins jenkins 4096 Jan 9 03:35 tools

Step 4: Jenkins config

Jenkins → manage → configure → Global properties → Environment variables as following:

Add Key-Value List

Key : ANDROID_HOME

Value : /var/lib/jenkins/android-sdk

《Jenkins Build Android APK手顺以及遇到问题的解决方案》

Error 3: Wrong NDK dependency

* What went wrong:

Starting a Gradle Daemon (subsequent builds will be faster)NDK is missing a “platforms” directory.If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /var/lib/jenkins/android-7.1.1/ndk-bundle.If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Error 3 Solution:

Change gradle build plugin version from com.android.tools.build:gradle:2.3.3  to  2.2.2

Reference:https://stackoverflow.com/questions/44730178/getting-warning-ndk-is-missing-a-platforms-directory-with-no-ndk

Error 4: Not accepted license agreements of the SDK

FAILURE: Build failed with an exception. 

* What went wrong:A problem occurred configuring project ‘:app’.> You have not accepted the license agreements of the following SDK components:  [Android SDK Build-Tools 25, 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

Error 4 Solution:

### login Jenkins server

bash-4.1$ cd /var/lib/jenkins/android-sdk/tools

bash-4.1$ bin/sdkmanager –licenses –no_https –proxy=http –proxy_host=proxy –proxy_port=9501

5 of 5 SDK package licenses not accepted.

Review licenses that have not been accepted (y/N)? y

All SDK package licenses accepted

done

Error 5: ConstraintLayout not install

Preparing “Install Solver for ConstraintLayout 1.0.2”.”Install Solver for ConstraintLayout 1.0.2″ ready.Finishing “Install Solver for ConstraintLayout 1.0.2″Installing Solver for ConstraintLayout 1.0.2 in /var/lib/jenkins/android-sdk/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2″Install Solver for ConstraintLayout 1.0.2” failed.Preparing “Install ConstraintLayout for Android 1.0.2”.”Install ConstraintLayout for Android 1.0.2″ ready.Finishing “Install ConstraintLayout for Android 1.0.2″Installing ConstraintLayout for Android 1.0.2 in /var/lib/jenkins/android-sdk/extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2″Install ConstraintLayout for Android 1.0.2” failed.FAILURE: Build failed with an exception.* What went wrong:A problem occurred configuring project ‘:app’.> Failed to install the following SDK components:  [ConstraintLayout for Android 1.0.2, Solver for ConstraintLayout 1.0.2]  Please install the missing components using the SDK manager in Android Studio.

Error 5 Solution:

### login Jenkins server

bash-4.1$ cd /var/lib/jenkins/android-sdk/tools

bash-4.1$ bin/sdkmanager “extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2” –no_https –proxy=http –proxy_host=proxy –proxy_port=9501

done

Error 6: Linux glibc api version not support build tool

:app:mergeDebugResourcesAAPT err(Facade for 340845695): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt)AAPT err(Facade for 340845695): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/lib64/libc++.so)Exception while processing task java.lang.RuntimeException: AAPT process not ready to receive commandsThread(png-cruncher_2): Broken pipejava.io.IOException: Broken pipeat java.io.FileOutputStream.writeBytes(Native Method)at java.io.FileOutputStream.write(FileOutputStream.java:326)at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)at com.android.builder.png.QueuedCruncher$1.destruction(QueuedCruncher.java:144)at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:245)at java.lang.Thread.run(Thread.java:745)AAPT err(Facade for 321808217): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt)AAPT err(Facade for 321808217): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/lib64/libc++.so)AAPT err(Facade for 1671206652): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt)AAPT err(Facade for 2028725799): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt)AAPT err(Facade for 2028725799): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/lib64/libc++.so)AAPT err(Facade for 1289475567): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt)AAPT err(Facade for 1289475567): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/lib64/libc++.so)AAPT err(Facade for 1671206652): /var/lib/jenkins/android-sdk/build-tools/25.0.0/aapt: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /var/lib/jenkins/android-sdk/build-tools/25.0.0/lib64/libc++.so)Exception while processing task java.lang.RuntimeException: AAPT process not ready to receive commandsException while processing task java.lang.RuntimeException: AAPT process not ready to receive commandsThread(png-cruncher_1): Broken pipe

Error 6 Solution:

这是因为sdk build tools 25.0.0编译依赖glibc2.14,glibc是linux系统底层api,几乎其它任何运行库都会依赖于glibc。所以如果不是很确定的话,不要轻易更改系统glibc。可以选择升级linux系统,但这显然也不是一个省事儿的办法,那么怎么办呢。

我们可以自己重新编译一个glibc2.14放在其他目录。

Step 1: download 

bash-4.1$ cd /var/lib/jenkins/

bash-4.1$ wget -e “http_proxy=http://proxy:80” http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz

–2018-01-09 14:55:45–  http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gzResolving proxy… xxxxConnecting to proxy|xxxx|:9501… connected.Proxy request sent, awaiting response… 200 OKLength: 20897040 (20M) [application/x-gzip]Saving to: “glibc-2.14.tar.gz”100%[==================================================================================================================================================================================================>] 20,897,040  4.80M/s  in 5.4s   2018-01-09 14:55:51 (3.72 MB/s) – “glibc-2.14.tar.gz” saved [20897040/20897040]

Step 2: unzip and install

bash-4.1$ tar zxvf glibc-2.14.tar.gz

bash-4.1$ cd glibc-2.14

bash-4.1$ mkdir build

bash-4.1$ cd build

bash-4.1$ ../configure -prefix=/var/lib/jenkins/glibc/glibc-2.14

bash-4.1$ make -j4      //will take 3mins

bash-4.1$ make install

bash-4.1$ cd /var/lib/jenkins/glibc/glibc-2.14/

bash-4.1$ ls -l

total 28

drwxr-xr-x  2 jenkins jenkins 4096 Jan  9 15:12 bin

drwxr-xr-x  2 jenkins jenkins 4096 Jan  9 15:12 etc

drwxr-xr-x 22 jenkins jenkins 4096 Jan  9 15:12 include

drwxr-xr-x  4 jenkins jenkins 4096 Jan  9 15:12 lib

drwxr-xr-x  3 jenkins jenkins 4096 Jan  9 15:12 libexec

drwxr-xr-x  2 jenkins jenkins 4096 Jan  9 15:12 sbin

drwxr-xr-x  5 jenkins jenkins 4096 Jan  9 15:12 share

Step 3: reset build tool glibc api version setting 

bash-4.1$ cd /var/lib/jenkins/android-sdk/build-tools/25.0.0

bash-4.1$ mv aapt aapt_

bash-4.1$ touch aapt

// Set the environment variable

bash-4.1$ less aapt

#!/bin/sh

echo “$0″_$@

export LD_LIBRARY_PATH=/var/lib/jenkins/glibc/glibc-2.14/lib && “$0″_ $@

aapt (END)

// Change file to be executable

bash-4.1$ chmod +x aapt

╰(*°▽°*)╯Run successfully!!!

APK Download Location

http://xxx/view/app-release-build/job/xxxx-mobile-app-release-build/ws/app/build/outputs/apk/


推荐阅读
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • 计算机存储系统的层次结构及其优势
    本文介绍了计算机存储系统的层次结构,包括高速缓存、主存储器和辅助存储器三个层次。通过分层存储数据可以提高程序的执行效率。计算机存储系统的层次结构将各种不同存储容量、存取速度和价格的存储器有机组合成整体,形成可寻址存储空间比主存储器空间大得多的存储整体。由于辅助存储器容量大、价格低,使得整体存储系统的平均价格降低。同时,高速缓存的存取速度可以和CPU的工作速度相匹配,进一步提高程序执行效率。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • 本文介绍了Windows操作系统的版本及其特点,包括Windows 7系统的6个版本:Starter、Home Basic、Home Premium、Professional、Enterprise、Ultimate。Windows操作系统是微软公司研发的一套操作系统,具有人机操作性优异、支持的应用软件较多、对硬件支持良好等优点。Windows 7 Starter是功能最少的版本,缺乏Aero特效功能,没有64位支持,最初设计不能同时运行三个以上应用程序。 ... [详细]
  • Linux服务器密码过期策略、登录次数限制、私钥登录等配置方法
    本文介绍了在Linux服务器上进行密码过期策略、登录次数限制、私钥登录等配置的方法。通过修改配置文件中的参数,可以设置密码的有效期、最小间隔时间、最小长度,并在密码过期前进行提示。同时还介绍了如何进行公钥登录和修改默认账户用户名的操作。详细步骤和注意事项可参考本文内容。 ... [详细]
  • Android中高级面试必知必会,积累总结
    本文介绍了Android中高级面试的必知必会内容,并总结了相关经验。文章指出,如今的Android市场对开发人员的要求更高,需要更专业的人才。同时,文章还给出了针对Android岗位的职责和要求,并提供了简历突出的建议。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 本文介绍了Java工具类库Hutool,该工具包封装了对文件、流、加密解密、转码、正则、线程、XML等JDK方法的封装,并提供了各种Util工具类。同时,还介绍了Hutool的组件,包括动态代理、布隆过滤、缓存、定时任务等功能。该工具包可以简化Java代码,提高开发效率。 ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • Oracle分析函数first_value()和last_value()的用法及原理
    本文介绍了Oracle分析函数first_value()和last_value()的用法和原理,以及在查询销售记录日期和部门中的应用。通过示例和解释,详细说明了first_value()和last_value()的功能和不同之处。同时,对于last_value()的结果出现不一样的情况进行了解释,并提供了理解last_value()默认统计范围的方法。该文对于使用Oracle分析函数的开发人员和数据库管理员具有参考价值。 ... [详细]
  • WebSocket与Socket.io的理解
    WebSocketprotocol是HTML5一种新的协议。它的最大特点就是,服务器可以主动向客户端推送信息,客户端也可以主动向服务器发送信息,是真正的双向平等对话,属于服务器推送 ... [详细]
  • 本文介绍了如何使用C#制作Java+Mysql+Tomcat环境安装程序,实现一键式安装。通过将JDK、Mysql、Tomcat三者制作成一个安装包,解决了客户在安装软件时的复杂配置和繁琐问题,便于管理软件版本和系统集成。具体步骤包括配置JDK环境变量和安装Mysql服务,其中使用了MySQL Server 5.5社区版和my.ini文件。安装方法为通过命令行将目录转到mysql的bin目录下,执行mysqld --install MySQL5命令。 ... [详细]
author-avatar
常思
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有