热门标签 | 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/


推荐阅读
  • RancherOS 是由 Rancher Labs 开发的一款专为 Docker 设计的轻量级 Linux 发行版,提供了一个全面的 Docker 运行环境。其引导镜像仅 20MB,非常适合在资源受限的环境中部署。本文将详细介绍如何在 ESXi 虚拟化平台上安装和配置 RancherOS,帮助用户快速搭建高效、稳定的容器化应用环境。 ... [详细]
  • 本文详细介绍了在 Ubuntu 系统上搭建 Hadoop 集群时遇到的 SSH 密钥认证问题及其解决方案。通过本文,读者可以了解如何在多台虚拟机之间实现无密码 SSH 登录,从而顺利启动 Hadoop 集群。 ... [详细]
  • 本文总结了在SQL Server数据库中编写和优化存储过程的经验和技巧,旨在帮助数据库开发人员提升存储过程的性能和可维护性。 ... [详细]
  • 如何在Linux服务器上配置MySQL和Tomcat的开机自动启动
    在Linux服务器上部署Web项目时,通常需要确保MySQL和Tomcat服务能够随系统启动而自动运行。本文将详细介绍如何在Linux环境中配置MySQL和Tomcat的开机自启动,以确保服务的稳定性和可靠性。通过合理的配置,可以有效避免因服务未启动而导致的项目故障。 ... [详细]
  • 使用ArcGIS for Java和Flex浏览自定义ArcGIS Server 9.3地图
    本文介绍了如何在Flex应用程序中实现浏览自定义ArcGIS Server 9.3发布的地图。这是一个基本的入门示例,适用于初学者。 ... [详细]
  • Spark与HBase结合处理大规模流量数据结构设计
    本文将详细介绍如何利用Spark和HBase进行大规模流量数据的分析与处理,包括数据结构的设计和优化方法。 ... [详细]
  • 优化后的标题:Apache Cassandra数据写入操作详解
    本文详细解析了 Apache Cassandra 中的数据写入操作,重点介绍了 INSERT 命令的使用方法。该命令主要用于将数据插入到指定表的列中,其基本语法为 `INSERT INTO 表名 (列1, 列2, ...) VALUES (值1, 值2, ...)`。通过具体的示例和应用场景,文章深入探讨了如何高效地执行数据写入操作,以提升系统的性能和可靠性。 ... [详细]
  • 解决Android应用在手机安装时出现安全风险提示的方法与对策
    解决Android应用在手机安装时出现安全风险提示的方法与对策 ... [详细]
  • 本文介绍了一种利用PHP cURL库高效提取Sohu邮箱联系人列表的方法。通过设置错误报告级别、定义Cookie文件路径等关键步骤,确保了代码的稳定性和可靠性。经过实际测试,该方法在2012年3月24日被验证为有效,能够快速准确地获取联系人信息。此外,文章还提供了详细的代码示例和注意事项,帮助开发者更好地理解和应用这一技术。 ... [详细]
  • 在Unity中进行3D建模的全面指南,详细介绍了市场上三种主要的3D建模工具:Blender 3D、Maya和3ds Max。每种工具的特点、优势及其在Unity开发中的应用将被深入探讨,帮助开发者选择最适合自己的建模软件。 ... [详细]
  • 深入解析Gradle中的Project核心组件
    在Gradle构建系统中,`Project` 是一个核心组件,扮演着至关重要的角色。通过使用 `./gradlew projects` 命令,可以清晰地列出当前项目结构中包含的所有子项目,这有助于开发者更好地理解和管理复杂的多模块项目。此外,`Project` 对象还提供了丰富的配置选项和生命周期管理功能,使得构建过程更加灵活高效。 ... [详细]
  • 深入解析 Android Drawable:第六阶段进阶指南 ... [详细]
  • Android ListView 自定义 CheckBox 实现列表项多选功能详解
    本文详细介绍了在Android开发中如何在ListView的每一行添加CheckBox,以实现列表项的多选功能。用户不仅可以通过点击复选框来选择项目,还可以通过点击列表的任意一行来完成选中操作,提升了用户体验和操作便捷性。同时,文章还探讨了相关的事件处理机制和布局优化技巧,帮助开发者更好地实现这一功能。 ... [详细]
  • APKAnalyzer(1):命令行操作体验与功能解析
    在对apkChecker进行深入研究后,自然而然地关注到了Android Studio中的APK分析功能。将APK文件导入IDE中,系统会自动解析并展示其中各类文件的详细信息。官方文档提供了详细的命令行工具使用指南,帮助开发者快速上手。本文以一个RecyclerView的Adapter代理开源库为例,探讨了如何利用这些工具进行高效的APK分析。 ... [详细]
  • 本文深入解析了如何通过自定义 ViewGroup 实现类似支付宝风格的酷炫雷达脉冲动画效果。文章详细介绍了自定义 ViewGroup 的原理和实现步骤,并结合实际案例展示了如何在 Android UI 设计中应用这一技术,为开发者提供了宝贵的参考和实践指导。 ... [详细]
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社区 版权所有