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

 

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 theANDROID_HOME variable in the system variables.

What seems to be the source of this error?

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

12 Answers

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.

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

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

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.

answered
Aug 22 '14 at 11:53
prayag upd

8,64055384
 

What worked for me in Android Studio (0.8.1):

  1. Right click on project name and open Module Settings
  2. Verify SDK Locations
  3. Verify Gradle and Plugin Versions (Review the error message hintsfor the proper version to use)
  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 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技术文章,二维码如下:(可扫描)

Android studio - Failed to find target android-18的更多相关文章

  1. Android Studio xcode单步调试 WebRTC Android & iOS

    mac环境 如何在 Android Studio 里单步调试 WebRTC Android 的 native 代码. WebRTC 代码下载 depot tools 是 chromium 代码库管理工 ...

  2. 解决Android Studio Conflict with dependency 'com.android.support:support-annotations'报错

    解决Android Studio Conflict with dependency 'com.android.support:support-annotations'报错 在Android Studi ...

  3. android studio 导入一个已有的android studio project作为lib使用

    android studio 导入一个已有的android studio project作为lib使用 新项目来了. 需要搭建框架. android studio对我来说还是很陌生,之前一个项目在同事 ...

  4. 【Android Studio使用教程3】Android Studio的一些设置 体验更好了

    Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面. Settings --> Appearance --> T ...

  5. Android studio 安装与配置【Android学习入门】

    终于下定决心认真学习Android开发了. 之前在很多平台看到很多大牛们学习Android的经验和心得,纸上得来终觉浅. 这里推荐stormzhang老师总结的Android学习之路. 为了防止电脑卡 ...

  6. 使用 Android Studio 开发工具创建一个 Android 应用程序,显示一行文字“Hello Android”,并将应用程序的名称更改为“FirstApp”。

    需求说明: 使用 Android Studio 开发工具创建一个 Android 应用程序,显示一行文字"Hello Android",并将应用程序的名称更改为"Firs ...

  7. 使用 Android Studio 开发工具创建一个 Android 应用程序,并在 Genymotion 模拟器上运行

    需求说明: 使用 Android Studio 开发工具创建一个 Android 应用程序,并在 Genymotion 模拟器上运行 实现步骤: 打开 Android Studio,创建一个 Andr ...

  8. Android Studio 之 no render target selected

    今天第一次使用android studio, 莫名其妙出现 no render target selected的错误,没有设计界面, 各种百度之后在 stackoverflow.com/questio ...

  9. android studio——Failed to set up SDK

    最近使用android studio ,在IDE里面使用Gradle构建的时候,一直出现构建失败,失败信息显示Failed to set up SDK.然后 提示无法找到andriod-14平台,我更 ...

随机推荐

  1. 有意思的c++题目

    #include <iostream> #include<stdlib.h> using namespace std; class A { public: int _a; A( ...

  2. webpack模块化管理和打包工具

    Webpack简介 webpack是当下最热门的前端资源模块化管理和打包工具.它可以将许多松散的模块按照依赖和规则打包成符合生产环境部署的前端资源.还可以将按需加载的模块进行代码分隔,等到实际 需要的 ...

  3. StandardContext

    错误信息: 2014-2-6 21:37:19 org.apache.catalina.startup.HostConfig checkResources信息: Reloading context [ ...

  4. 规约模式(Specification Pattern)

    一.引言 最近在看一个项目的源码时(DDD),对里面的一些设计思想和设计思路有了一些疑问.当看到(Repository层)中使用了 spec.SatisfiedBy() 时,感觉有点懵.于是在项目中搜 ...

  5. POI ZAW

    要求一个最短路,担心的就是一条边被正反经过两次. 规定第一步为1到i,并把这条边设为不可经过.然后从i做最短路到1,因为这个过程是不会经历重边的(如果经历了就不是最短路了). 求最短路用SPFA,但常 ...

  6. [BZOJ]4197: [Noi2015]寿司晚宴

    Time Limit: 10 Sec  Memory Limit: 512 MB Description 为了庆祝 NOI 的成功开幕,主办方为大家准备了一场寿司晚宴.小 G 和小 W 作为参加 NO ...

  7. ●ZOJ 2112 Dynamic Rankings

    ●赘述题目 对于一个长为n(n<50000)的序列(序列中的数小于1000000000),现有如下两种指令: Q a b c:询问区间[a,b]中第c小的数. C p b:将序列中的从左往右数第 ...

  8. bzoj 2229: [Zjoi2011]最小割

    Description 小白在图论课上学到了一个新的概念--最小割,下课后小白在笔记本上写下了如下这段话: "对于一个图,某个对图中结点的划分将图中所有结点分成两个部分,如果结点s,t不在同 ...

  9. [SHOI2001]化工厂装箱员

    题目描述 118号工厂是世界唯一秘密提炼锎的化工厂,由于提炼锎的难度非常高,技术不是十分完善,所以工厂生产的锎成品可能会有3种不同的纯度,A:100%,B:1%,C:0.01%,为了出售方便,必须 ...

  10. 勤拂拭软件 java web 开发教程(1) - 开发环境搭建

    勤拂拭软件系列教程 之 Java Web开发之旅(1) Java Web开发环境搭建 1 前言 工作过程中,遇到不少朋友想要学习jsp开发,然而第一步都迈不出,连一个基本的环境都没有,试问,如何能够继 ...