Error while changing API level from 23 to 22

11.6k Views Asked by At

I want to change the minimum SDK version in Android Studio from API 23 to API 22 as HttpClient is not supported in API 23.I have tried changing it in build.gradle(Module:app) ie I have changed the compileSdkVersion from 23 to 22 and targetSdkVersion from 23 to 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'
}

Then, sync and rebuild the project. But i got the following error in 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.

The error is in the file v23\values-v23.xml

Any help will be greatly appreciated. Thanks!!!

6

There are 6 best solutions below

1
On BEST ANSWER

After some research, I got Apache HTTP client working even in API 23 using org.apache.http.legacy.jar library. Following configuration worked.

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')
} 

I manually copied org.apache.http.legacy.jar from Android/Sdk/platforms/android-23/optional folder to app/libs in my project,then added

useLibrary 'org.apache.http.legacy'  

inside android{...} tag.

1
On

Change it in your AndroidManifest.xml

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

Cheers

0
On

Try changing

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

To

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

Do this alongwith compileSdkVersion targetSdkVersion set to 22

1
On

Use this,

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'
}
0
On
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'
}

Note: Change folder name from "values-v23" to "values-v22"

0
On

The error arise because you've used sdk version 23 and build tools 22.0.1. Update the build tools to the latest (download them also). Here's the configuration:

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: : Until async-http library is updated, you can use this:

android {
    useLibrary 'org.apache.http.legacy'
}