Build a continuous integration system for Android automatic compilation

Source: Internet
Author: User

Because of our expertise, we use auto build, so we use the CI system.

CodeManagement uses SVN, automatic compilation uses ant, continuous integration uses Hudson, and the operating system uses ubuntu10.04.

1. Install JDK 1.1

Sudo apt-Get install sun-java6-jdk

1.2 install ant

Sudo apt-Get install ant-optional

1.3 install Hudson

Sudo apt-Get upgrade
Wget-O/tmp/key http://hudson-ci.org/debian/hudson-ci.org.key
Sudo apt-key Add/tmp/Key
Http://hudson-ci.org/latest/debian/hudson.deb wget-O/tmp/Hudson. Deb
Sudo dpkg -- install/tmp/Hudson. Deb

1.4 install Android SDK

Http://androidappdocs.appspot.com/sdk/index.html

2. Configure Project 2.1 build. xml

Http://androidappdocs.appspot.com/guide/developing/other-ide.html

According to official practices, you can use the automatically generated build file.

  <?  XML version = "1.0" encoding = "UTF-8"  ?>  
< Project Name = "Test-android" >

<! -- The local. properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It shoshould ** not * be checked in version
Control systems. -->
< Property File = "Local. properties" />

<! -- the build. properties file can be created by you and is never touched
by the 'android' tool. this is the place to change some of the default property values
used by the ant rules.
here are some properties you may want to change/update:
application. package
the name of your application package as defined in the manifest. used by the
'uninstall' rule.
source. dir
the name of the source directory. default is 'src '.
out. dir
the name of the output directory. default is 'bin '.
properties related to the SDK location or the project target shocould be updated
using the 'android' tool with the 'update' action.
this file is an integral part of the build system for your application and
shocould be checked in version control systems.
-->
< Property File = "Build. properties" />

<! -- The default. properties file is created and updated by the 'android' tool, as well
As ADT.
This file is an integral part of the build system for your application and
Shocould be checked in version control systems. -->
< Property File = "Default. properties" />

<! -- Custom Android task to deal with the project target, and import the proper rules.
This requires ant 1.6.0 or above. -->
< Path ID = "Android. antlibs" >
< Pathelement Path = "$ {SDK. dir}/tools/lib/anttasks. Jar" />
< Pathelement Path = "$ {SDK. dir}/tools/lib/sdklib. Jar" />
< Pathelement Path = "$ {SDK. dir}/tools/lib/androidprefs. Jar" />
< Pathelement Path = "$ {SDK. dir}/tools/lib/apkbuilder. Jar" />
< Pathelement Path = "$ {SDK. dir}/tools/lib/jarutils. Jar" />
</ Path >

< Taskdef Name = "Setup" Classname = "Com. Android. Ant. setuptask" Classpathref = "Android. antlibs" />

<! -- Execute the android setup task that will setup some properties specific to the target,
And import the build rules files.

The rules file is imported from
<SDK>/platforms/<target_platform>/templates/android_rules.xml

To customize some Build Steps for your project:
-Copy the content of the main node <project> from android_rules.xml
-Paste it in this build. xml below the <Setup/> task.
-Disable the import by changing the setup task below to <setup import = "false"/>

This will ensure that the properties are setup correctly but that your customized
Build Steps are used.
-->
< Setup />

</ Project >

 

2.2 local. Properties

 
This configuration file defines the location of the android SDK
 
SDK. dir =$ {tool. Android. SDK}
2.3 build. Properties

This file defines the package of the app and some configurations required to generate the app signature.

Application. Package = test. Android
Key. Store = ../test-android.keystore
Key. Alias = test-android
Key. Store. Password = Password
Key. Alias. Password = Password

3. Configure Hudson 3.1 System Configuration

The system configuration is simple. You only need to configure the JDK and ant positions.

Another useful item is e-mail Notification. If you need to send an email when build fails, you need to configure this item.

3.2 job configuration3.2.1 source code management

1. Select subversion and set the svn address, user name, and password.

2. Select use update and revert.

3.2.2 build triggers

1. Check build periodically and set the automatic build time. The syntax here is the same as that of cron.

Example: 0 2 ** 1-6

2. Check poll SCM and set the interval at which SVN changes are detected.

Example: 0, 15, 30, 45 9-23 ** 1-5

3.2.3 build

Step 1: Delete the last compiled file

Rm-F test-android.keystore
Rm-F-R./test-android/Gen
Rm-F-R./test-android/bin

Step 2: generate a keystore

Http://androidappdocs.appspot.com/guide/publishing/app-signing.html

Example: keytool-genkey-v-alias test-Android-keyalg RSA-keysize 2048-dname 'cn = xxx, ou = xxx, O = xxx, L = xxx, st = xxx, c = xx'-validity 10000-keypass password-storepass password-keystore' test-android. keystore'

Step 3: invoke ant

Set targets: release-dsdk. dir = $ your-SDK-Dir

Example: release-dsdk. dir =/home/build/Android-SDK-Linux

3.2.3 post-build actions

1. Check archive the artifacts and set files to archive: Test-android/bin/test-android-release.apk

2. Check email notification to set the email sending object and time.

 

After setting the above steps, you are done.

Professional is so easy !!!

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.