Failed resolution of: Lorg/apache/hc/core5/http/message/BasicNameValuePair;

这是我引用的库文件

implementation ("com.esri.arcgisruntime:arcgis-android:100.15.3")

使用ArcGIS绘制天地图报错如下:

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/hc/core5/http/message/BasicNameValuePair;

查询资料得知是Android 9以后不支持 http库并删除掉该库,Google官方推荐使用HttpURLConnection,但是ArcGIS是多平台开发,还是引用了Http,导致找不到该库文件

以下是常规Groovy构建build.gradle文件

groovy 复制代码
android {
   defaultConfig {
       // 1.加入这句话
       useLibrary 'org.apache.http.legacy'
   }

   packagingOptions {
       // 2.加入这句话
       exclude 'META-INF/DEPENDENCIES'
       exclude 'META-INF/NOTICE'
       exclude 'META-INF/LICENSE'
       exclude 'META-INF/LICENSE.txt'
       exclude 'META-INF/NOTICE.txt'
   }
}

dependencies {
   //3.加入这句话
   api 'org.apache.httpcomponents.client5:httpclient5:5.3'
}

由于我使用的是kotlin构建项目

所以build.gradle.kts修改如下

kotlin 复制代码
android {
   defaultConfig {
       // 1.加入这句话
       useLibrary("org.apache.http.legacy")
   }

// 2.加入这句话
    packagingOptions(Action {
        excludes.add("META-INF/LGPL2.1")
        excludes.add("META-INF/LICENSE")
        excludes.add ("META-INF/NOTICE")
        excludes.add("META-INF/DEPENDENCIES")
        excludes.add("META-INF/LICENSE.txt")
        excludes.add("META-INF/NOTICE.txt")
    })
}

dependencies {
   //3.加入这句话
   api ("org.apache.httpcomponents.client5:httpclient5:5.3")
}
相关推荐
ps酷教程1 小时前
HttpPostRequestDecoder源码浅析
java·http·netty
汤愈韬2 小时前
双向NAT
网络·网络协议·网络安全·security·huawei
xifangge20252 小时前
PHP 错误日志在哪里看?Apache / Nginx / PHP-FPM 一次讲清
nginx·php·apache
*才华有限公司*2 小时前
RTSP视频流播放系统
java·git·websocket·网络协议·信息与通信
寻星探路3 小时前
【Python 全栈测开之路】Python 基础语法精讲(一):常量、变量与运算符
java·开发语言·c++·python·http·ai·c#
栗子叶3 小时前
网页接收服务端消息的几种方式
前端·websocket·http·通信
Filotimo_5 小时前
桥接服务概念
网络协议·网络安全·信息与通信
镜中人★5 小时前
408计算机网络考纲知识点(更新中)
网络·网络协议·计算机网络
禾叙_6 小时前
【netty】Netty之TCP链接
网络·网络协议·tcp/ip
半路_出家ren7 小时前
17.python爬虫基础,基于正则表达式的爬虫,基于BeautifulSoup的爬虫
网络·爬虫·python·网络协议·正则表达式·网络爬虫·beautifulsoup