Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SDK Download as Part of Gradle Build

I am trying build an Android app with Jenkins and I have little control over Jenkins' slave machines.

In order to build the app I need the Android SDK installed on the slave, otherwise I get as expected:

"SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable."

That being the case, can gradle be configured to download the SDK as part of the build process and use it as a normal dependency?

Does this even make sense?

Thanks for the help.

like image 727
FelipeFraga Avatar asked Oct 06 '17 17:10

FelipeFraga


1 Answers

The Gradle Android plugin supports automatic downloading of missing dependencies at build time; the trick is that accepted license agreements pertaining to the Android SDK must be bundled with the project to be built.

You basically just copy over the accepted license agreements from one spot where they have been accepted through Android Studio (your dev workstation probably), and ensure that they are copied as in to the Android SDK Home Directory on the Jenkins slave.

The files can be found in a license/ folder in the Android SDK folder, although the official documentation refers to the directory as licenses/.

like image 66
cstarner Avatar answered Sep 27 '22 23:09

cstarner