android工作室项目中找不到org.apache.http jar类 [英] org.apache.http jar class not found in android studio projects

查看:221
本文介绍了android工作室项目中找不到org.apache.http jar类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我包括以下罐子,见下图。

i include following jars see below image.

我想整合json网络服务,所以我在jars下面导入

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

当我设置上面的结构我的jar文件没有得到在我的班级文件中,我知道如何解决这个问题?你的所有建议都很明显。

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.

编辑

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


推荐答案

自API级别23以来已删除Apache HTTP客户端:

Apache HTTP Client was removed since API level 23:


此预览将删除对Apache HTTP客户端的支持。如果您的应用
正在使用此客户端并且定位到Android 2.3(API级别9)或更高版本,则
将使用HttpURLConnection类。此API更有效
,因为它通过透明压缩和
响应缓存减少了网络使用,并最大限度地降低了功耗。要继续使用
Apache HTTP API,必须首先在build.gradle文件中声明以下
编译时依赖项:

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正在从OpenSSL转向BoringSSL库。如果您在应用中使用Android NDK
,请不要链接
不属于NDK API的加密库​​,例如
libcrypto.so和libssl.so 。这些库不是公共API,并且
可能会在发行版和设备之间发生更改或中断,恕不另行通知。在
中,您可能会面临安全漏洞。
相反,修改您的本机代码以通过JNI调用Java加密API
或静态链接到
选项的加密库。

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.

参考:

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

这篇关于android工作室项目中找不到org.apache.http jar类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆