[英]Error: failed to find target with hash string 'android-21'
I want to change my compileSdkVersion from 23 to 21.So I have made following changes in the build.gradle but I am getting following error.How can I resolve this? 我想将我的compileSdkVersion从23更改为21.因此我在build.gradle中进行了以下更改,但是我收到了以下错误。如何解决此问题?
failed to find target with hash string 'android-21' 无法使用哈希字符串'android-21'找到目标
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.shalabh.fly"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile files('libs/httpclient-4.1-beta1.jar')
}
You are using 您正在使用
compile 'com.android.support:appcompat-v7:23.0.1'
So you have to compile with API 23. 所以你必须使用API 23进行编译。
Change your compileSdkVersion
in your build.gradle
file 更改
compileSdkVersion
在你build.gradle
文件
compileSdkVersion 23
Below is for Android studio 1. Go to app -> build.gradle -> change "compileSdkVersion 'installed sdk version'" 以下是针对Android studio 1.转到app - > build.gradle - >更改“compileSdkVersion'已安装的sdk版本'”
That's it, problem solved:-) 就是这样,问题解决了:-)
Note: I think this might be a bug in Android Studio.
注意:我认为这可能是Android Studio中的错误。
If this not work, then: 如果这不起作用,那么:
Go to you Android SDK dir and install it properly: 转到Android SDK目录并正确安装:
tools/android update sdk
or 要么
tools/android update sdk --no-ui
Just check android home environment variable, it should be : path/../path/sdk and not : path/.../path/sdk/tools example: android home path is : /home/username/android/sdk you should put the following lines to .bashrc file in user home directory: 刚检查android主页环境变量,它应该是:path /../ path / sdk而不是:path /.../ path / sdk / tools例子:android主路径是:/ home / username / android / sdk你应该将以下行放在用户主目录中的.bashrc文件中:
ANDROID_HOME='/home/username/android/sdk'
PATH="$HOME:$HOME/bin:$ANDROID_HOME/tools:$PATH"
export ANDROID_HOME
export PATH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.