Search code examples
androidsdkandroid-min-sdk

Error while changing API level from 23 to 22


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!!!


Solution

  • 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.