我想将Android Studio中的最低SDK版本从API 23更改为API 22,因为API 23不支持HttpClient。我尝试在build.gradle(Module:app)中更改它,即我已经更改了compileSdkVersion 23到22和targetSdkVersion从23到22。
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.test.gcmgreetingapp"
minSdkVersion 11
targetSdkVersion 23
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.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile project(':android-query-full.0.26.7')
compile 'com.loopj.android:android-async-http:1.4.8'
}
然后,同步并重建项目。但是我在gradle控制台中出现了以下错误
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:TextAppearance.Material.Widget.Button.Inverse\u0027.","sources":[{"file":"C:\\Users\\nischal.manandhar\\AndroidStudioProjects\\GCMGreetingApp\\app\\build\\intermediates\\exploded-aar\\com.android.support\\appcompat-v7\\23.0.0\\res\\values-v23\\values-v23.xml","position":{"startLine":1}}],"original":""}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:Widget.Material.Button.Colored\u0027.","sources":[{"file":"C:\\Users\\nischal.manandhar\\AndroidStudioProjects\\GCMGreetingApp\\app\\build\\intermediates\\exploded-aar\\com.android.support\\appcompat-v7\\23.0.0\\res\\values-v23\\values-v23.xml","position":{"startLine":1}}],"original":""}
FAILED
FAILURE: Build failed with an exception.
错误位于文件v23 \ values-v23.xml
中任何帮助将不胜感激。谢谢!!!
答案 0 :(得分:2)
在 AndroidManifest.xml
中更改它 <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
干杯
答案 1 :(得分:2)
尝试更改
compile 'com.android.support:appcompat-v7:23.0.0'
到
compile 'com.android.support:appcompat-v7:22.2.0'
将此compileSdkVersion
targetSdkVersion
设置为22
答案 2 :(得分:2)
使用此,
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "au.com.websutra.gcmgreetingapp"
minSdkVersion 11
targetSdkVersion 22
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:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile project(':android-query-full.0.26.7')
compile 'com.loopj.android:android-async-http:1.4.6'
}
答案 3 :(得分:2)
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "au.com.websutra.gcmgreetingapp"
minSdkVersion 11
targetSdkVersion 22
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:22.2.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile project(':android-query-full.0.26.7')
compile 'com.loopj.android:android-async-http:1.4.8'
}
注意:将文件夹名称从“values-v23”更改为“values-v22”
答案 4 :(得分:1)
由于您使用了sdk version 23
和build tools 22.0.1
,因此出现错误。
将构建工具更新到最新版本(也可以下载它们)。这是配置:
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.test.gcmgreetingapp"
minSdkVersion 11
targetSdkVersion 23
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.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile project(':android-query-full.0.26.7')
compile 'com.loopj.android:android-async-http:1.4.8'
}
更新:在更新async-http
库之前,您可以使用此功能:
android {
useLibrary 'org.apache.http.legacy'
}
答案 5 :(得分:1)
经过一些研究,我使用org.apache.http.legacy.jar库让Apache HTTP客户端在API 23中工作。以下配置工作。
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.test.gcmgreetingapp"
minSdkVersion 14
targetSdkVersion 23
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.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile project(':android-query-full.0.26.7')
compile 'com.loopj.android:android-async-http:1.4.8'
compile files('libs/org.apache.http.legacy.jar')
}
我手动将 org.apache.http.legacy.jar 从 Android / Sdk / platforms / android-23 / optional 文件夹复制到我项目中的app / libs,然后添加
useLibrary 'org.apache.http.legacy'
在android {...}标记内。