30

I cannot for the life of me find any reference on the internet for how to setup TeamCity to build Android Studio projects.

I've found links to IntelliJ Idea and TeamCity, to Gradle and TeamCity, but nothing specifically on building an Android Studio project in TeamCity.

Can anyone point me in the right direction?

Dr. Andrew Burnett-Thompson
  • 19,227
  • 6
  • 78
  • 159

2 Answers2

33

Thanks to Yole's direction, I've set this up now.

The steps if anyone is interested are below:

  1. Install Gradle on the build agent server. I took the gradle-2.3.bin from http://gradle.org/downloads and copied to C:\gradle-2.3
  2. Set the environment variable GRADLE_HOME = C:\gradle-2.3
  3. Install Android Studio on the build agent server. This should also install the Android SDK
  4. Set the environment variable ANDROID_HOME = C:\Users\%Current User%\AppData\Local\Android\sdk
  5. Restart the TeamCity agent server
  6. Setup your build configuration with the Gradle runner, setting Gradle tasks to 'clean build' and setting the Gradle Home path. Set working directory to the project directory for your Android project

Run the build!

enter image description here

Community
  • 1
  • 1
Dr. Andrew Burnett-Thompson
  • 19,227
  • 6
  • 78
  • 159
  • can u pls tell how can i do implementation of TeamCity in Android Studio project ? – Erum Jun 16 '16 at 05:12
  • I thought I did ^ :) You need to ensure you can build your Android project via Gradle. That's the first task and separate to TeamCity. Once you have that you can use the TeamCity Gradle Task Runner to execute your gradle tasks. The only part where we got stuck was configuring the build server with environment variables and SDKs. – Dr. Andrew Burnett-Thompson Jun 16 '16 at 08:33
  • i knw the first part and i have installed TEAMCITY but getting issue for 2nd point can u pls help me @Dr. ABT – Erum Jun 16 '16 at 08:38
  • Trying this on Docker so maybe it's a bit different and I see this is from 2015, but I keep getting "No Compatible Agents" errors when I try to build. Base on this answer, I don't see when/where to install an Agent. – Chris Feb 26 '18 at 21:01
  • The TeamCity directory contains a default build agent by the name of buildAgent, you can go in that folder and run it. – Ahmed Shahid May 11 '20 at 08:26
5

There is nothing specific about building an Android Studio project on TeamCity. It's just a Gradle project, and you need to configure it as such.

yole
  • 80,603
  • 15
  • 224
  • 177
  • That's great, thanks. I'm working through it now. have installed Gradle, Android SDK on build server and now get a happy 'Build Success!'. The logs look suspiciously empty ... I'll keep digging but thanks for pointing me in the right direction – Dr. Andrew Burnett-Thompson Mar 03 '15 at 21:34
  • My impression is that installing the Android SDK should not be necessary. build.gradle lists all the dependencies of your Android project, and Gradle should be able to download them automatically. – yole Mar 03 '15 at 21:55
  • TeamCity complained of ANDROID_HOME missing on the target machine. Something to do with local.properties not being a part of the commit http://stackoverflow.com/questions/22765997/android-sdk-location-vs-build-server-how-to-set-it – Dr. Andrew Burnett-Thompson Mar 03 '15 at 22:02
  • @yole can u pls share how to setup teamcity for phonegap based projects ? – Erum Jun 17 '16 at 05:56
  • I found that TeamCity downloaded Gradle automatically and installed it (very sleek), but not so with Android Studio. I'm using TeamCity Professional 2018.1.1 (build 58406). – Nick Wright Nov 21 '18 at 17:25