Mastering Android NDK
上QQ阅读APP看书,第一时间看更新

Using TeamCity continuous integration server with Android applications

TeamCity is a powerful continuous integration and deployment server, which can be used to automate your Android application builds. This can be found at https://www.jetbrains.com/teamcity.

Note

TeamCity is free for small projects that require no more than 20 build configurations and 3 build agents and is absolutely free for open source projects. Ask for an open-source license at https://www.jetbrains.com/teamcity/buy.

The server installation procedure is straightforward. Windows, OS X, or Linux machine can be used as the server or a build agent. Here, we will show how to install TeamCity on Windows.

Download the latest version of the installer from https://www.jetbrains.com/teamcity/download and run it using the following command:

>TeamCity-9.0.1.exe

Install all components and run it as Windows Service. For simplicity, we will run both the server and the agent on a single machine, as shown in the following screenshot:

Using TeamCity continuous integration server with Android applications

Choose the desired TeamCity server port. We will use the default HTTP port 80. Run the TeamCity Server and Agent services under the SYSTEM account.

Once the server is online, open your browser and connect to it using the address http://localhost. Create a new project and a build configuration.

Note

To work with TeamCity, you should put the source code of your project into a version control system. Git and GitHub will be a good choice.

If your project is already on GitHub, you can create a Git VCS root pointing to the URL of your GitHub repository, like this https://github.com/<your login>/<your project>.git.

Add a new command-line build step and type the content of the script:

ndk-build
ant release

You can also add signing using jarsigner here and use the zipalign tool to create the final production .apk.

Now, go to the General Settings step and add an artifact path to bin/3_NDK-release.apk. The project is ready for continuous integration.