Tutorials Android Bamboo Continuous Integration for Android

Bamboo Continuous Integration for Android

1. Introduction

Here in this tutorial, we’ll show you the importance of continuous integration tools in software development process and steps to configure Bamboo for building android code.

Most developers use Eclipse as IDE for their development. IDE makes life simplified with the ease to set up, code and build the source. All you have to do is to install and follow some of the screen instructions to run your code.

Eclipse will help you to build your source code and run it on device. Now let us move a step ahead. What if we need to have a continuous integration for android project? Before we begin, let us understand the importance of continuous integration in project.

2. Why Continuous Integration?

Continuous integration or “CI” is the process of fully automating the compilation and build generation process. There are several benefits of having a Continuous Integration system integrated in your project

  • Fully automated: Saves time of developers for making build for each release
  • From Source Control: A CI takes the code from your favourite source code from repository, it could be SVN, git etc. CI server will check for any updates available on the source code, as soon as there is an update, it will trigger the build process
  • Always Compile latest code: This is a way to make sure we are building from the latest source code from repository
  • Distribute the latest application build to your beta testers (Optional).

3. Getting Started with Bamboo

The building process of Continuous integration tool is slightly different than your eclipse IDE. This uses several steps for setting up the project and lines to compile your code.

  1. Download Source Code
  2. Compile and Build Source code
  3. Generate .APK file
  4. Sign APK file
  5. Distribute APK file (out of scope in this tutorial)

The above steps are important to prepare your android build and distribute to your beta testers. Distribution application to beta tester is optional in this case. I will include it in another tutorial.

Here in this example, we will see how to configure bamboo for building android.

4. Login to Bamboo

Login to Bamboo with your valid bamboo account credentials.

5. Create a New Plan

Select “Create” and then “Create a new plan” button in the top navigation bar. Create a new plan under an existing project or as a new project.

Plan: Plan defines the build process. Here you define what gets built, how the build is triggered and what job gets executed. Each plan will have a default job when it is created. You can add more jobs later.

Once created, click on Atlassian Bamboo – Build Dashboard and select the project and then newly created plan  from the list.

Create New Plan in Bamboo

6. Configuring the Plan

Select your plan. Find “Actions” drop down to the right side of your screen and then click “Configure plan” option.

You will notice a default “Job” will be created for you.

6.1. Checkout Source Code

Add task as source code checkout (by default this will get created). In this step bamboo connects you to git, github, svn or any other source code version controller system. This step will pull the source code from the specified path and will place the code in “build-dir” folder.
Create New Plan in Bamboo

6.2. Update Android Project

Add Another task “Command” type and do the below configurations. Add below snippet as arguments and save the task

update project --target "android-19" --path ./Android_LoginApp --name LoginTestApp

Update Android Project

More more info on above command visit

http://developer.android.com/tools/projects/projects-cmdline.html

6.3. Build Android Code using Ant

Add another task to build the project. Select “Ant” form add task. And do the below configurations

  1. Add new executable as “ant” if not available before and add the ant executable path in your computer
  2. Add arguments as below syntax.
release

Add ant  task

And now you’re done. Just hit “Run” button in your top right. This should start executing the batch and build the .apk for you.

Task Ant Build Configuration

6.4. Sign Android Project

Now we have the apk ready after the above step. Once we have the .apk file, we need to sign it with jarsigner.

What is jarsigner?

The jarsigner tool is used for two purposes. To sign Java ARchive (JAR) files, and to verify the signatures and integrity of signed JAR files. The JAR feature enables the packaging of class files, images, sounds, and other digital data in a single file for faster and easier distribution. A tool named jar enables developers to produce JAR files. (Technically, any zip file can also be considered a JAR file, although when created by jar or processed by jarsigner, JAR files also contain a META-INF/MANIFEST.MF file.). Read more..

Add Another task “Command” type and do the following configurations.

  1. Add new executable as “jarsigner” if not available before. “jarsigner” will be present in your java SDK. Redirect to your jarsigner sdk.
  2. Add arguments as below syntax.
-verbose -sigalg MD5withRSA -digestalg SHA1 -keystore docs/android.keystore-storepass <keystore password> <Path to your unsigned apk>  <your_alias>

Sign Android Project in Bamboo

6.5. Zip Align your APK

What is ZipAlign ?

zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the .apk, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application. Read more..

Add Another task “Command” type and do the following configurations.

 -v 4 <path to your unsigned apk> <name of your new apk include .apk extn>

Zip Align andorid APK

The result of the above path is the apk that can be distributed to your beta or internal testing team.

7. References

http://developer.android.com/tools/help/zipalign.html
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/jarsigner.html
https://confluence.atlassian.com

 

Total
0
Shares
guest
7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Javatechig
Javatechig
7 years ago

updated with more steps to sign apk and zipalign.

Sreedhu Madhu
Sreedhu Madhu
7 years ago

In my case executables dropdown list is empty could not proceed after second step, please help me.

Nilanchala Panigrahy
Nilanchala Panigrahy
7 years ago
Reply to  Sreedhu Madhu

You need to first add the list of executable to bamboo. Once they are installed, it will list out everything for project.

Akshay Kelkar
Akshay Kelkar
6 years ago
Reply to  Sreedhu Madhu

Hi Sreedhu,
Are you able to add executable in Bamboo ? If yes can you please share a link or some guideline for this since I am also not getting this option.

Shalin Gupta
Shalin Gupta
3 years ago

It is saying no agent found

Shalin Gupta
Shalin Gupta
3 years ago

Where to locate the apk

Harish
Harish
2 years ago

don’t forget to run an agent through terminal before running plan.

Previous Post
Java Tutorials

Covariant return type example in java

Next Post
Java Tutorials

Invoke Method Using Java Reflection

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All
7
0
Would love your thoughts, please comment.x
()
x