如何在Android Studio(Gradle)中添加apache commons集合

如何在Android Studio(Gradle)中添加apache commons集合,android,gradle,Android,Gradle,我正在尝试使用ListUtils 但当我运行应用程序时,我遇到了以下错误: Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.collections.ListUtils" on path: DexPathList[[zip file "/data/app/com.meridianaspect.wiw-2/base.apk"],nativeLibraryDirectories=[/

我正在尝试使用ListUtils 但当我运行应用程序时,我遇到了以下错误:

 Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.collections.ListUtils" on path: DexPathList[[zip file "/data/app/com.meridianaspect.wiw-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

所以我想我必须通过gradle导入这个库,但我不知道怎么做?

将jar文件放在模块根目录下的libs文件夹中。然后单击文件->项目设置。在左侧选择要添加此库的模块,在右侧选择tab Dependencies。在底部按加号,然后单击文件依赖项。然后选择您的jar和sync项目

选择您需要的项目并将它们添加到
build.gradle
的依赖项块:

我建议检查链接以确保您获得的是最新版本。请随意提出编辑建议

收藏

lang

压缩

net

io

exec

编解码器

http

验证程序

数学



看看所有的

有没有办法在Gradle中放置一些文本并处理jar文件和模块?@J.K.你的意思是简单地删除jar而不指定每个jar?不,我的意思是不删除任何jar,只需告诉gradle从org.apache.commons:commons-collections4:4.0中获取什么repo,然后按加号。另一个选项是库依赖项和搜索-键入名称并搜索您感兴趣的库和lang,
org.apache.commons:commons-lang3:3.4
。来源:对于net,编译“commons-net:commons-net:3.3”@Chad你能告诉我,
FilenameUtils
是哪个依赖项吗?@Iqbal它在IO:
compile“commons-IO:commons-IO:2.5”
为什么集合没有循环ifobuffer?我找不到它。BufferUtilsHttpClient已经是Android的一部分,但已经从API 23+中过时:
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'org.apache.commons:commons-compress:1.19'
implementation 'commons-net:commons-net:3.6'
implementation 'commons-io:commons-io:2.6'
implementation 'org.apache.commons:commons-exec:1.3'
implementation 'commons-codec:commons-codec:1.13'
implementation 'org.apache.httpcomponents:httpclient:4.5.10'
implementation 'commons-validator:commons-validator:1.6'
implementation 'org.apache.commons:commons-math3:3.6.1'