将 API 级别从 23 更改为 22 时出错
Error while changing API level from 23 to 22
我想将 Android Studio 中的最低 SDK 版本从 API 23 更改为 API 22,因为 API 23.I 不支持 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 console
中收到以下错误
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
任何帮助将不胜感激。谢谢!!!
在您的AndroidManifest.xml
中更改它
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
干杯
尝试改变
compile 'com.android.support:appcompat-v7:23.0.0'
到
compile 'com.android.support:appcompat-v7:22.2.0'
将 compileSdkVersion
targetSdkVersion
设置为 22
使用这个,
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'
}
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"
出现错误是因为您使用了 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'
}
UPDATE: : 在 async-http
库更新之前,你可以使用这个:
android {
useLibrary 'org.apache.http.legacy'
}
经过一些研究,我使用 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{...} 标签内。
我想将 Android Studio 中的最低 SDK 版本从 API 23 更改为 API 22,因为 API 23.I 不支持 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 console
中收到以下错误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
任何帮助将不胜感激。谢谢!!!
在您的AndroidManifest.xml
中更改它 <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
干杯
尝试改变
compile 'com.android.support:appcompat-v7:23.0.0'
到
compile 'com.android.support:appcompat-v7:22.2.0'
将 compileSdkVersion
targetSdkVersion
设置为 22
使用这个,
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'
}
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"
出现错误是因为您使用了 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'
}
UPDATE: : 在 async-http
库更新之前,你可以使用这个:
android {
useLibrary 'org.apache.http.legacy'
}
经过一些研究,我使用 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{...} 标签内。