问题
I want to create a build server for my Android Application. I am working with TeamCity. My problem is:
- Build server which is a PC (Windows) doesn't see Android SDK location.
- PC on which server runs has ANDROID_HOME set in right way.
- My application uses Gradle build system.
What I need to do is to make my build server use environment location (ANDROID_HOME) during build of my app. What have I already tried?
- I used local.properties in my Android Project. I tried to set ANDROID_HOME parameter to sdk.dir in various ways for example.
sdk.dir = ANDROID_HOME
result - error:
The SDK directory 'E:\TeamCity\buildAgent\work\a6d423a9d6e29c40\ANDROID_HOME' does not exist.
So as you can see, server adds some strange directory before. Same goes for: $ANDROID_HOME or %ANDROID_HOME%.
- When I set path manually and point to SDK direction on server so:
sdk.dir = /Program Files (x86)/android-studio/sdk
Then server builds the project and everything is right. ANDROID_HOME environment variable is set to same location as this.
- I deleted local.properties and I get this:
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
So how I understand this is: if I won't have local.properties in my project it will look for SDK path in ANDROID_HOME environment variable. Like I said, on my server environment variable is set and I've checked it many times. It doesn't work. (I tried it also on MAC X OS, terminal displays ANDROID_HOME as /Applications/Android Studio.app/sdk but for example Android Studio is able to build project only if I hardcode path in local.properties. It doesn't want to accept ANDROID_HOME variable in any way.)
How can I set environment variable in local.properties so I don't have to hardcode it to make it work?
回答1:
Thanks for interesting link. It is a great project but in my situation it doesn't give me what I really need. I managed to configure my TaxiCity project by doing:
- Every worker has it's own local.properties on PC that are not pushed to repo with commits.
- TeamCity builds project from repo but there is no local.properties - because of that he will look for ANDROID_HOME or give error if won't find it.
- Because setting ANDROID_HOME environment variable on PC which is a server doesn't work, I found a workaround which is: setting ANDROID_HOME variable inside TeamCity server file - buildAgent.properties
- TeamCity can't find local.properties (because it's not on repo), gets SDK location installed on server from ANDROID_HOME variable located in buildAgent.properties file
回答2:
I hope that this will help solve the problem: https://github.com/JakeWharton/sdk-manager-plugin
来源:https://stackoverflow.com/questions/22765997/android-sdk-location-vs-build-server-how-to-set-it