-1

i include following jars see below image. enter image description here

I want to integrate json web service so i import below jars

apache-mim44j-0.-6.jar
gson-2.1.jar
httpmime-4.0.1.jar
json_simple-1.1.jar

build.gradle file

apply plugin: 'com.android.application'

 android {
compileSdkVersion 23
buildToolsVersion '22.0.1'


 defaultConfig {
    applicationId "pkg.android.myapp"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"


}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
 }


  }


   dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
   compile 'com.android.support:appcompat-v7:23.0.1'
  }

when i set above structure my jar file is not getting in my class file any idea how can i solve this problem?your all suggestions are appreciable.

EDIT

apply plugin: 'com.android.application'

 android {
compileSdkVersion 23
buildToolsVersion '22.0.1'


 defaultConfig {
    applicationId "pkg.android.myapp"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"


}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
 }


  }

 android {
 useLibrary 'org.apache.http.legacy'
 }
   dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
   compile 'com.android.support:appcompat-v7:23.0.1'
  }
mbmc
  • 5,024
  • 5
  • 25
  • 53
Harshal Kalavadiya
  • 2,412
  • 4
  • 38
  • 71
  • you try like this go module setting of the application select the dependencies and press add button 3 option come select file dependencies add the jar file – Nithinlal Sep 21 '15 at 08:30
  • Nithinlal : can you expalin in more detail i m not getting – Harshal Kalavadiya Sep 21 '15 at 08:34
  • possible duplicate of [HttpClient won't import in Android Studio](http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio) – Selvin Sep 21 '15 at 08:34
  • compile files('libs/apache-mim44j-0.-6.jar') add this to build. gradle and try – Nithinlal Sep 21 '15 at 08:36
  • Right click on your project and select the module setting -> select the tab dependencies -> you can see a plus button on the right side -> while press this button you got 3 option -> select the file dependencies -> while doing this a window will option select your jar which needed to add – Nithinlal Sep 21 '15 at 08:43
  • Nithinlal : i try same thing but still not working – Harshal Kalavadiya Sep 21 '15 at 08:45

2 Answers2

1

Apache HTTP Client was removed since API level 23:

This preview removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

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

Android is moving away from OpenSSL to the BoringSSL library. If you’re using the Android NDK in your app, don't link against cryptographic libraries that are not a part of the NDK API, such as libcrypto.so and libssl.so. These libraries are not public APIs, and may change or break without notice across releases and devices. In addition, you may expose yourself to security vulnerabilities. Instead, modify your native code to call the Java cryptography APIs via JNI or to statically link against a cryptography library of your choice.

Reference:
https://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client

Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94
  • Mattia : see my edit portion i make change as per your answer but still class not found – Harshal Kalavadiya Sep 21 '15 at 09:23
  • You already have an element `android`. Don't create another one, just add `useLibrary 'org.apache.http.legacy'` in the existing element. – Mattia Maestrini Sep 21 '15 at 09:26
  • Mattia: [http://pastie.org/10435380](http://pastie.org/10435380) see this link any modification needed because still not getting sucess – Harshal Kalavadiya Sep 21 '15 at 09:46
  • What is the version of Gradle tools you use? You need the version 1.3.0, check your project-level build.gradle. – Mattia Maestrini Sep 21 '15 at 10:00
  • i have com.android.tools.build:gradle:1.3.0' gradle level – Harshal Kalavadiya Sep 21 '15 at 11:06
  • It's a known bug https://code.google.com/p/android/issues/detail?id=181474. Android Studio can't find the classes and gives errors, but the project builds correctly. The bug is marked as FutureRelease, so we need to wait a new release of Android Studio that fix the issue. In the meantime you can still use Apache HTTP Client ignoring the class not found error – Mattia Maestrini Sep 21 '15 at 12:59
0

You can use this link to download all libs. and then include

httpclient-4.5.1.jar httpcore-4.4.3.jar

and if get confilcts use these lines in buil.gradel

android {
 packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }
}

if get any more, click on highlited import and Alt+Enter. got solved by this

Community
  • 1
  • 1