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?

1
  • 7
    -voters. Any comment why you've down voted this? It's a legitimate question, and answer not yet found on SO. SO often deals with team city setup questions. Mar 3, 2015 at 21:33

2 Answers 2

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

5
  • can u pls tell how can i do implementation of TeamCity in Android Studio project ?
    – Erum
    Jun 16, 2016 at 5: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. Jun 16, 2016 at 8: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, 2016 at 8: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, 2018 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. May 11, 2020 at 8: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.

5
  • 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 Mar 3, 2015 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 3, 2015 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 stackoverflow.com/questions/22765997/… Mar 3, 2015 at 22:02
  • @yole can u pls share how to setup teamcity for phonegap based projects ?
    – Erum
    Jun 17, 2016 at 5: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). Nov 21, 2018 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.