Full trap hack: Continuous integration in Jenkins in a Linux environment Androidproject

Source: Internet
Author: User
Tags lua

This scenario takes the Rhel/centos 64-bit Linux operating system as an example, as this is the most common server environment right now.

First, install the Java SDK.


Suggest, do not use such as yum, such as the initiative to install themselves, because the openjdk and other things finally a variety of a moth can't get up. Old and honest to the Oracle site download at least JAVA7 64-bit version number finally. Manually installed, configure the system path and JAVA_HOME environment variables.

vim ~/.bash_profileexport JAVA_HOME=<Java安装路径>PATH=$PATH:$JAVA_HOME/bin……

Second, install the Android SDK Management tool.
The idea is to go to the Google site on the Linux version of the Android SDK Management tool compression package to get down, assuming that Google (Chinese characteristics you understand) on the Internet to find IP address with host and other methods to get it done.

wget https://dl.google.com/android/android-sdk_r23.0.2-linux.tgz

Then it is the decompression configuration environment variable, and finally make sure that the "Android" command is available in the system is the purpose.
Edit ~/.bash_profile Add system path 2 pieces:

PATH=$PATH:$your_android-sdk-linux/toolsPATH=$PATH:$your_android-sdk-linux/platform-toolsexport PATH

64-bit System please set this environment variable:

export ANDROID_SWT=$your_android-sdk-linux/tools/lib/x86_64# 假设是32位系统则这样设置:# export ANDROID_SWT=$your_android-sdk-linux/tools/lib/x86

Check to see if it's OK after it's finished. Execute command:

-h

Third, install ant in order to perform its own active compilation script.


It is recommended to honestly download Apache ant, Note: android-sdk_r23.0.2 must be above the ANT 1.8 version number, unzip it, and configure its Bin folder to the system execution path. The process no longer nonsense ~
You may experience problems during:

Java.lang.ClassNotFoundException:org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp

This solves:

sudo yum install ant-apache-regexp

or (Ubuntu system)

sudo apt-get install ant-optional

Iv. Download the Android SDK.
The idea is to first look at what version number of the SDK, their number, and then choose the download you need. Let's say the full download is too much, in China. Slow. You'll have to take care of these things. For example, the following command:

# 查看远程全部的SDKlist--all# 查看本地已安装的SDKlist target# 只下载编号为27的SDK,--no-ui 不须要启动图形界面--no-ui --all --filter 27# 下载 platform-tools和android-19--no-ui -u --all --filter platform-tools,android-19# 下载全部的SDK(不建议这样做)--no-ui

Start to try to build the project
Android engineering generally does not have ant build file build.xml. It is therefore necessary to perform the following command in the project root folder such as:

update project -p .

You may encounter issues such as the following:

Execute failed: java.io"/android/sdk/build-tools/android-4.1/aapt"error=2

The workaround:

-y compat-libstdc++-296.-y compat-libstdc++-33.
/android/sdk/build-tools/android-4.1whileshared libraries: libz.so.1opensharedfilefileor directory

The workaround:

install -y zlib
/android/sdk/build-tools/android-4.1whileshared libraries: libstdc++.so.6opensharedfilefileor directory

The workaround:

yuminstall-ylibstdc++.so.6
errorwhileshared libraries: libz.so.1shared obj

The workaround:

install -y zlib.i686

Vi. setting up Jenkins and setting the relevant environment.


Analyze code quality you need to findbugs.
It is recommended that you download Findbugs 2.0.3 and then unzip it to a folder even if it is installed. Then copy the Findbugs-ant.jar to the Ant_home/lib folder.
In the "Android-sdk/tools/ant" This folder to create findbugs-exclude.xml this file, but findbugs do not scan non-Java code, content such as the following:

<?xml version= "1.0" encoding= "UTF-8"?><findbugsfilter>  <Match>    <Class name="~.*\." r\$.* "/>    <Bug Code="Nm"/>  </Match>  <Match>    <Class name="~.*\." manifest\$.* "/>    <Bug Code="Nm"/>  </Match></findbugsfilter>

Then edit "Android-sdk/tools/ant/build.xml" to add FindBugs's build task:

<taskdef name= "findbugs" classname=" Edu.umd.cs.findbugs.anttask.FindBugsTask "/><target name="FindBugs">  <mkdir dir="reports" />    <findbugs Home="< your findbugs installation folder >" output="xml"  outputFile= "reports/findbugs.xml" excludefilter=" Findbugs-exclude.xml ">      <auxclasspath path="${project.target.android.jar}"/>      <auxclasspath>              <fileset dir="Libs" includes="*.jar" />                                                  </auxclasspath>      <class location ="${out.dir}" />      <sourcepath path="${source.dir}" />    </findbugs></target>

The official standard practice is to suggest this. I think it's too much trouble. For references:

< property name= "findbugs.home" value="${env. Findbugs_home} " />  <path id="Findbugs_lib">      <fileset dir="${findbugs.home}/lib/">          <include name="*.jar"/>      </fileset>  </path>  <taskdef name= "findbugs" classname=" Edu.umd.cs.findbugs.anttask.FindBugsTask " classpathref=" Findbugs_lib " />  <target name="FindBugs" depends="-compile">      <mkdir dir="reports" />      <findbugs Home="${findbugs.home}" output="html" outputFile="reports/${ant.project.name}_findbugs.html">          <auxclasspath path="${android.jar}" />          <auxclasspath>              <fileset dir="${other-dependency-lib-dir}/libs" includes="*.jar" />          </auxclasspath>          <class location ="${out.dir}" />          <sourcepath path="${source.dir}" />      </findbugs>  </target>

Finally, start a pleasant operation with Jenkins:
First configure Findbugs.home and Android-sdk.home in the Jenkins System environment variable console, you know.


Then "build a free-style software project" in Jenkins.
In the project, add the "build step" in the following order, for example:
Execute Shell
Command

androidupdateproject-p.--targetandroid-19

Invoke Ant
Targets

cleandebugfindbugslint

See, the FindBugs command is the ant build task we just configured.
The lint command requires Jenkins to install the response plugin, which is not mentioned here.

References:
Http://www.cnblogs.com/ifantastic/p/3981295.html
Https://www.digitalocean.com/community/tutorials/how-to-build-android-apps-with-jenkins
Http://stackoverflow.com/questions/17963508/how-to-install-android-sdk-build-tools-on-the-command-line
http://wolfgangkiefer.blog.163.com/blog/static/86265503201310206246960

Full trap hack: Continuous integration in Jenkins in a Linux environment Androidproject

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.