Full-trap cracking: continuous integration of Android projects in Jenkins in Linux

Source: Internet
Author: User

Full-trap cracking: continuous integration of Android projects in Jenkins in Linux

This solution takes RHEL/Centos 64-bit Linux as an example, because this is currently the most common server environment.

1. Install the Java SDK.
We recommend that you do not use automatic installation such as yum, because Dongdong, such as openJDK, cannot run all sorts of moths. Go to the oracle website to download the final Java 7 64-bit version. Install it manually and configure the system path and JAVA_HOME environment variables.

Vim ~ /. Bash_profileexport JAVA_HOME =
  
   
PATH = $ PATH: $ JAVA_HOME/bin ......
  

2. Install the Android SDK management tool.
The idea is to go to the Google website to compress the Android SDK management tool for Linux. If you cannot access Google (You know it with Chinese characteristics), you can find an IP address and host on the Internet.

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

Then, decompress and configure the environment variables to ensure that the "android" command is available in the system.
Edit ~ /. Add bash_profile to the system path:

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

For 64-bit systems, set this environment variable:

Export ANDROID_SWT = $ your_android-sdk-linux/tools/lib/x86_64 # if it is a 32-bit system, it is set as follows: # export ANDROID_SWT = $ your_android-sdk-linux/tools/lib/x86

After the event, check whether it is OK and run the following command:

android -h

3. Install Ant to execute the automatic compilation script.
It is recommended to honestly download Apache Ant, note: android-sdk_r23.0.2 must be Ant 1.8 or later, extract it, and configure its bin directory to the system execution path. The process is no longer nonsense ~
During this period, problems may occur:

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

This solution:

sudo yum install ant-apache-regexp

Or (Ubuntu System)

sudo apt-get install ant-optional

4. Download the Android SDK.
The idea is to first check which versions of sdks are available and how their numbers are, and then select the desired download. If all the sdks are downloaded, there will be too many. In China, the download speed will be slow. To solve these problems, you will use the following command:

# View all SDKandroid list sdks remotely -- all # view locally installed SDKandroid list target # Only download sdks numbered 27, -- no-ui does not need to start the graphical interface android update sdk -- no-ui -- all -- filter 27 # download platform-tools and android-19android update sdk -- no-ui-u -- all -- filter platform -tools, android-19 # download all sdks (not recommended) android update SDK -- no-ui

5. Start to build the project
The Android project generally does not have the Ant build File build. xml. Therefore, you need to run the following command in the project root directory to test whether the file can be generated:

android update project -p .

You may encounter the following problems:

Execute failed: java.io.IOException: Cannot run program /android/sdk/build-tools/android-4.1/aapt: error=2

Solution:

yum install -y compat-libstdc++-296.i686 yum install -y compat-libstdc++-33.i686 
/android/sdk/build-tools/android-4.1/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

Solution:

yum install -y zlib
/android/sdk/build-tools/android-4.1/aapt: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

Solution:

yum install -y libstdc++.so.6
error while loading shared libraries: libz.so.1: cannot open shared obj

Solution:

yum install -y zlib.i686

6. Set Jenkins and related environments.
You need Findbugs to analyze the code quality.
Therefore, we recommend that you download Findbugs 2.0.3 and decompress it to a directory. Then copy the findbugs-ant.jar to the ANT_HOME/lib directory.
Create the findbugs-exclude.xml file in the "android-sdk/tools/ant" directory, but the findbugs does not scan non-Java code, the content is as follows:


  
    
       
        
       
     
    
     
       
        
       
     
    
   
  

Edit "android-sdk/tools/ant/build. xml" and add the findbugs build task:


  
     
        
     
      
Output = xml outputFile = reports/findbugs. xml excludeFilter = findbugs-exclude.xml>
       
            
       
        
       
      
     
    
   
  

The official standard practice is as follows. I think it is too troublesome for reference:


    
     
   
   
    
      
     
    
   
  

Finally, start to operate Jenkins happily:
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.
Add the "Build Steps" in the following order in the project ":
Execute shell
Command

android update project -p . --target android-19

Invoke Ant
Targets

cleandebugfindbugslint

As you can see, the findbugs command is the Ant build task we Just configured.
The lint Command requires Jenkins to install the response plug-in.

 

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.