Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Android Studio project on Jenkins? android.compileSdkVersion is missing

I'm trying to set up my first Android project to build on Jenkins.

I'm running Jenkins 1.6.2 with version 1.24 of the Gradle plugin. Running on Windows 7 Professional SP1.

I've installed Android Studio and the Java7 JDK on my build machine, and a checked-out version of the software builds just fine, through Android Studio or when running gradlew.bat from the command line. But I can't get the Invoke Gradle script build task to work, within my Jenkins job.

There is a pair of radio buttons, on the configure project page:

  • Invoke Gradle
  • Use Gradle Wrapper

If I select "Invoke Gradle", I'm asked to select a "Gradle Version", which is something I setup in Configure System.

I created a gradle installation with GRADLE_HOME set to "D:\Program Files\Android Studio\gradle\gradle-2.2.1". That gives me a warning that "D:\Program Files\Android Studio\gradle\gradle-2.2.1 is not a directory on the Jenkins master...."

And when I run a build, I get an error "Can't retrieve the Gradle executable".

Which is probably related to the gradle plugin complaining about the directory. But the directory is correct. I've tried it with '/' instead of '\', and it made no difference.

Since that didn't work, I tried the alternative, "Use Gradle Wrapper". There's a checkbox: "From Root Build Script Dir". Whether I check it, or not, I get "java.lang.IllegalArgumentException: android.compileSdkVersion is missing!"

I've set both JAVA_HOME and ANDROID_HOME, so that's not the issue.

Any ideas?

As a followup, I delete the gradle task, and added an Execute Windows batch command task:

SET ANDROID_HOME=d:\Program Files\Android\sdk
SET JAVA_HOME=d:\Program Files\Java\jdk1.7.0_79

.\gradlew.bat clean

When I run that, I still get that error.

But when I run those commands from a command line on the build machine, they work just fine.

What could be different, when running gradlew.bat from Jenkins, than when running it from the command line? The Jenkins service is configured to use the same user as I'm logged in as, when I'm running from the command line. I've tried explicitly setting each and every environment variable I have set in the command line, in the Jenkins task, and I'm still seeing the error.

Any ideas?

like image 994
Jeff Dege Avatar asked May 04 '15 23:05

Jeff Dege


People also ask

Where is the .gradle file android?

Located in the project/module directory of the project this Gradle script is where all the dependencies are defined and where the SDK versions are declared.

How to add build Gradle in Android Studio?

Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project. Click Build > Make Project to test your build file by building your project and address any errors you find.


1 Answers

Your local.properties file must contain: sdk.dir="path to your android sdk"

like image 95
Kemp Avatar answered Sep 17 '22 12:09

Kemp