Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio - Failed to find target android-18

I have a problem with Android Studio 0.2.3.

When I run my project the build stops and appears message that says:

Gradle: Execution failed for task ':AppName:compileDebugAidl'.
> failed to find target android-18

although I have installed the SDK platform of Android 4.3 (API 18) and I tried to reinstall all the SDK. I've also added the ANDROID_HOME variable in the system variables.

What seems to be the source of this error?

like image 808
RobertoAV96 Avatar asked Aug 05 '13 22:08

RobertoAV96


4 Answers

I think you might not have the Android-18 sdk installed. Go to Tools > Android > SDK Manager and check to see if Android 4.3 (API 18) is installed.

like image 94
Calvin Li Avatar answered Nov 13 '22 06:11

Calvin Li


I solved the problem by changing the compileSdkVersion in the Gradle.build file from 18 to 17.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 18
    }
}

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
}
like image 34
RobertoAV96 Avatar answered Nov 13 '22 05:11

RobertoAV96


STEP 1) Start Android SDK Manager

With android command something as below,

$ /usr/local/android-studio/sdk/tools/android

STEP 2) Find API 18

enter image description here

STEP 3) Select Android 4.3 (API 18 ) and install packages.

like image 10
prayagupa Avatar answered Nov 13 '22 05:11

prayagupa


What worked for me in Android Studio (0.8.1):

  1. Right click on project name and open Module Settings
  2. Verify SDK Locations SDK
  3. Verify Gradle and Plugin Versions (Review the error message hints for the proper version to use) Gradke
  4. On the app Module set the Compile SDK Version to android-L (latest)
  5. Set the Build Tools version to largest available value (in my case 20.0.0) Build

These changes via the UI make the equivalent changes represented in other answers but is a better way to proceed because on close, all appropriate files (current and future) will be updated automatically (which is helpful when confronted by the many places where issues can occur).

NB: It is very important to review the Event Log and note that Android Studio provides helpful messages on alternative ways to resolve such issues.

like image 5
Tommie C. Avatar answered Nov 13 '22 05:11

Tommie C.