4

我想将 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 中

任何帮助将不胜感激。谢谢!!!

4

6 回答 6

2

在您的AndroidManifest.xml中更改它

    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />

干杯

于 2015-08-20T11:04:28.283 回答
2

尝试改变

compile 'com.android.support:appcompat-v7:23.0.0'

compile 'com.android.support:appcompat-v7:22.2.0'

执行此compileSdkVersion targetSdkVersion操作并设置为22

于 2015-08-20T11:12:44.373 回答
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'
}
于 2015-08-20T11:19:24.780 回答
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”

于 2015-08-20T11:22:16.417 回答
1

出现错误是因为您使用了sdk version 23and 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'
}
于 2015-08-20T11:26:55.387 回答
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.jarAndroid/Sdk/platforms/android-23/optional文件夹复制到我项目中的 app/libs,然后添加

useLibrary 'org.apache.http.legacy'  

在 android{...} 标签内。

于 2015-08-21T11:35:07.997 回答