I'm trying to open my android project in Android Studio and when I open it I get the error in the library
Unable to find optional library: org.apache.http.legacy
I do not understand why...
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.user.activofijo"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.android.support:design:23.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mobsandgeeks:android-saripaar:2.0.2'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.mcxiaoke.volley:library:1.0.+'
}
Since you use a
compileSdkVersion 23
you should stop using the apache libraries for connection and use HttpURLConnection .To solve your problem,
add the
.jar
directly to the folder/libs
.The .jar can be downloaded from the Apache Software Foundation
*I recommend you switch to HttpURLConnection
add these lines to your gradle file
in the SDK manager update the Android SDK tools rev 24.4.1 and SDK platform tools to version 23.1. Then restart android studio.
I use this version of the library