您的位置:首页 > 移动开发 > Android开发

Android studio - Failed to find target android-18

2016-11-02 00:08 507 查看
看了一下国外的解决方案,好多人也都遇到此类问题。看老外的聊天,由衷觉得着实的可爱,同时外国的月亮也不见得比国内的圆。以下是他们的对话(最后有一个小总结):

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?

java

android
gradle


android-studio
shareimprove
this question
editedJun 8 '15 at 20:23



vaxquis
5,89752542

asked
Aug 5 '13 at 22:33



RobertoAV96
1,5033813

what is your minimum target for project? – Dave
Alperovich Aug
5 '13 at 22:59
Android 2.3.3 (API 10) – RobertoAV96Aug
6 '13 at 10:06
1
Settings the ANDROID_HOME variable in my .bash_profile to my Android Studio sdk location (where I downloaded v18) fixed this for me! – Daniel
Smith Aug
30 '13 at 16:47
add a comment

12 Answers

activeoldest

votes

up vote111

down vote
accepted
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.

shareimprove
this answer
answered
Sep 28 '13 at 21:09



Calvin Li
1,2451711

9
In fact, when I had the problem, the Android-18 sdk was installed, but I think Android Studio didn't detect it. I've resolved by uninstalling and reinstalling SDK and Studio.
RobertoAV96Sep
29 '13 at 11:04
3
When I received a similar error, just restarting Android Studio was sufficient rather than a complete reinstall. – Code-ApprenticeFeb
10 at 20:01
1
Restarting the mac was the only thing that let IntelliJ see the newly installed SDKs for me. – codeulikeFeb
11 at 15:51
add a comment





up vote45

down vote
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.+'
}


shareimprove
this answer
editedSep 11 at 11:24



iraj jelodari
660730

answered
Aug 6 '13 at 16:03



RobertoAV96
1,5033813

good job. I think same would have been accomplished if you advanced your minimum target. In fact, it probly wouldnt run on a 2.3.3 – Dave
Alperovich Aug
6 '13 at 16:49
It run on Android 2.3.3, I tried it on emulator and device. – RobertoAV96Aug
6 '13 at 17:04
interesting.... – Dave AlperovichAug
6 '13 at 20:03
2
This really isn't a solution to the problem especially if you are trying to use features available only in 18+ – Daniel
Smith Aug
30 '13 at 16:30
How do you make it just use the latest SDK instead? I have a similar issue with this library:github.com/devunwired/custom-view-examples
, and even though I've made similar steps, I get this error. – android developerSep
21 '14 at 21:13
add a comment
up vote10

down vote

STEP 1) Start Android SDK Manager

With
android
command something as below,

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

STEP 2) Find API 18



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

shareimprove
this answer
answered
Aug 22 '14 at 11:53



prayag upd
8,64055384

add a comment
up vote4

down vote
What worked for me in Android Studio (0.8.1):

Right click on project name and open Module Settings
Verify SDK Locations


Verify Gradle and Plugin Versions (Review the error message hintsfor the proper version to use)


On the app Module set the Compile SDK Version to android-L (latest)
Set the Build Tools version to largest available value (in my case20.0.0)


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.

。。。。。。。等等

总结:

主要原因在于:你导入项目的编译版本是18,但是你的studio不存在这个版本。

对于万能的解决方案,没有具体的。但是大致两种方案

1:开启sdkmanager 自动选择下载。

2:去网上下载一个sdk-18版本,复制到platforms里面。重启studio即可。

以上两种方案,老外也这么解决的,如果还是不行,另寻高就了~

欢迎关注公众号,每天推送Android技术文章,二维码如下:(可扫描)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐