Android, Java

Failed to find target android-18… D’oh!

One of the first problems I’ve found on my Android adventure is to configure the environment. Although there are lots of tutorials and IDEs to do it for me, I’ve decided to start building my “toys” with the newest building tool, Gradle (http://www.gradle.org).

The first impressions with gradle were good, however once I started to configure the project as Android application, a strange issue started to appear in my console, an error telling me that the compiler failed to find the target android:

My Computer:project-dir user$ gradle assemble

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':mobile-app:packageDebug'.
> failed to find target android-18

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.56 secs

This started to happen once I introduced the android plugin in the gradle config file:

apply plugin: 'android'

android {
compileSdkVersion 18
buildToolsVersion "18.0.0"
}

dependencies {...}

So, after googling a bit, I discovered that the problem was that I wasn’t pointing to the sdk version I had installed, so I opened /adt/sdk/tools/android:

android_sdk_manager

And, change the buildToolsVersion with the installed version:

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.0.3”
}

dependencies {...}

Once I did this everything started to work fine. Easy, simple and… obvious, d’oh!

Advertisements
Standard