OsanaBuvi
OsanaBuvi

Reputation: 11

The system cannot find the file(httpclient-4.0.1.jar) specified in android studio?

The system cannot find the file (httpclient-4.0.1.jar) specified in android studio ?

I am trying to create a new app in Android Studio, When I try to Run or debug it shows a compile time error like :

Error:Execution failed for task ':SampleApp:compileDebugJavaWithJavac'.
> java.io.FileNotFoundException: C:\Users\VM\Desktop\SampleApp\libs\httpclient-4.0.1.jar (The system cannot find the file specified)

build.gradle(Module:SampleApp) file

apply plugin: 'com.android.application' android {

    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.app.SampleApp"
        minSdkVersion 14
        targetSdkVersion 23
      manifestPlaceholders = [manifestApplicationId : "${applicationId}",
           onesignal_app_id  : " ",
           onesignal_google_project_number: ""]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    } } dependencies {
    compile project(':library_pull_to_refresh')
    compile project(':view_pager_indicator')
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.google.android.gms:play-services-ads:7+'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile files('libs/httpclient-4.0.1.jar')
    compile files('libs/universal-image-loader-1.8.6.jar')
    compile 'com.onesignal:OneSignal:2.+@aar'
    compile 'com.google.android.gms:play-services-gcm:7+'
    compile 'com.google.android.gms:play-services-analytics:7+' }

Even after that I can't find any solution.

Please any one guide me.

Upvotes: 0

Views: 516

Answers (3)

Hetfieldan24
Hetfieldan24

Reputation: 198

From where you downloaded your .jar file? I just downloaded it from "https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.0.1" right now and it works. Upd.: also you can try to add "compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.0.1'" instead "compile files('libs/httpclient-4.0.1.jar')"

Upvotes: 0

Nithinlal
Nithinlal

Reputation: 5061

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

Upvotes: 1

Vishal Thakkar
Vishal Thakkar

Reputation: 682

If you are using HttpClient for http request and response you can use HTTP Library by adding this line in your app gradle instead of adding jar file :-

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

Upvotes: 0

Related Questions