Setting up TeamCity to build Android Studio project

17,535

Solution 1

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

Solution 2

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.

Share:
17,535
Dr. Andrew Burnett-Thompson
Author by

Dr. Andrew Burnett-Thompson

Andrew Burnett-Thompson is the CEO & Founder at SciChart, a High Performance Realtime WPF, iOS/Android & JavaScript Charts, I have experience in high performance software (C#, WPF, C, C++), algorithms, data-visualization (DirectX, OpenGL), JavaScript, WebAssembly and mobile app development in scientific, banking and trading systems. Follow me on twitter at https://twitter.com/@drandrewbt where I tweet about entrepreneurship, coding & programming, health & fitness, and more.

Updated on June 16, 2022

Comments

  • Dr. Andrew Burnett-Thompson
    Dr. Andrew Burnett-Thompson almost 2 years

    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
    Dr. Andrew Burnett-Thompson about 9 years
    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
  • yole
    yole about 9 years
    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.
  • Dr. Andrew Burnett-Thompson
    Dr. Andrew Burnett-Thompson about 9 years
    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/…
  • Erum
    Erum almost 8 years
    can u pls tell how can i do implementation of TeamCity in Android Studio project ?
  • Dr. Andrew Burnett-Thompson
    Dr. Andrew Burnett-Thompson almost 8 years
    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.
  • Erum
    Erum almost 8 years
    i knw the first part and i have installed TEAMCITY but getting issue for 2nd point can u pls help me @Dr. ABT
  • Erum
    Erum almost 8 years
    @yole can u pls share how to setup teamcity for phonegap based projects ?
  • Chris
    Chris about 6 years
    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.
  • Nick Wright
    Nick Wright over 5 years
    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).
  • Ahmed Shahid
    Ahmed Shahid almost 4 years
    The TeamCity directory contains a default build agent by the name of buildAgent, you can go in that folder and run it.