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

我正在尝试使用 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]]

所以我想我必须以某种方式导入那个图书馆,但我不知道如何做到这一点?

107962 次浏览

将 jar 文件放在模块根目录下的 libs 文件夹中。然后文件-> 项目设置。在左侧选择要添加这个库的模块,在右侧选择选项卡 Dependency。在底部按 Plus 标志,然后单击“文件依赖项”。然后选择 jar 并同步项目

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

我建议你检查一下这个链接,以确保你得到的是最新的版本。

馆藏 : < a href = “ http://mvnRepository.com/artif/org.apache.commons/commons-Collections4”rel = “ noReferrer”> (link)

implementation 'org.apache.commons:commons-collections4:4.4'

Lang : < a href = “ http://mvnRepository.com/artif/org.apache.commons/commons-lang3”rel = “ noReferrer”> (link)

implementation 'org.apache.commons:commons-lang3:3.9'

压缩 : < a href = “ http://mvnRepository.com/左图/org.apache.commons/commons-compress”rel = “ noReferrer”> (link)

implementation 'org.apache.commons:commons-compress:1.19'

Net : < a href = “ http://mvnRepository.com/artis/commons-net/commons-net”rel = “ noReferrer”> (link)

implementation 'commons-net:commons-net:3.6'

Io : < a href = “ http://mvnRepository.com/artis/commons-io/commons-io”rel = “ noReferrer”> (link)

implementation 'commons-io:commons-io:2.6'

Exec < a href = “ http://mvnstoreitory.com/artif/org.apache.commons/commons-exec”rel = “ noReferrer”> (link)

implementation 'org.apache.commons:commons-exec:1.3'

编解码器 < a href = “ http://mvnRepository.com/artis/commons-codec/commons-codec”rel = “ noReferrer”> (link)

implementation 'commons-codec:commons-codec:1.13'

Http://strong > < a href = “ http://mvnstoreitory.com/神器/org.apache.httpComponent/httpclient”rel = “ noReferrer”> (link)

implementation 'org.apache.httpcomponents:httpclient:4.5.10'

Validator < a href = “ http://mvnRepository.com/artis/commons-validator/commons-validator”rel = “ noReferrer”> (link)

implementation 'commons-validator:commons-validator:1.6'

一个 href = “ http://mvnstoreitory.com/神器/org.apache.commons/commons-math3”rel = “ noReferrer”> (链接)

implementation 'org.apache.commons:commons-math3:3.6.1'

看看所有的 这里是 Apache 库