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")
}
相关推荐
程序员-珍3 小时前
虚拟机ip突然看不了了
linux·网络·网络协议·tcp/ip·centos
魏大橙5 小时前
linux RCE本地/公网测试
网络·网络协议·udp
l1x1n05 小时前
No.3 笔记 | Web安全基础:Web1.0 - 3.0 发展史
前端·http·html
鄃鳕6 小时前
HTTP【网络】
网络·网络协议·http
读心悦7 小时前
如何在 Axios 中封装事件中心EventEmitter
javascript·http
CXDNW8 小时前
【网络篇】计算机网络——应用层详述(笔记)
服务器·笔记·计算机网络·http·web·cdn·dns
秋夫人10 小时前
http cache-control
网络·网络协议·http
叶北辰CHINA10 小时前
nginx反向代理,负载均衡,HTTP配置简述(说人话)
linux·运维·nginx·http·云原生·https·负载均衡
zhangphil12 小时前
Windows环境Apache httpd 2.4 web服务器加载PHP8:Hello,world!
php·apache·httpd
小白学大数据12 小时前
User-Agent在WebMagic爬虫中的重要性
开发语言·爬虫·http