123

Im trying to use ListUtils but when I ran the app I got this error:

 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]] 

So I guess I have to import that library via gradle somehow, but I dont know how to do that?

1

2 Answers 2

495

Pick the ones you need and add them to build.gradle's dependencies block:

I recommend checking the link to make sure you are getting the latest version. Feel free to suggest edits.

collections: (link)

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

lang: (link)

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

compress: (link)

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

net: (link)

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

io: (link)

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

exec (link)

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

codec (link)

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

http (link)

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

validator (link)

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

math (link)

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

See all of the Apache libraries here

Sign up to request clarification or add additional context in comments.

10 Comments

and for lang, org.apache.commons:commons-lang3:3.4. source: mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.4
and for net, compile 'commons-net:commons-net:3.3'
@Chad Could you please tell in which dependency, FilenameUtils is?
@Iqbal it's in IO: compile 'commons-io:commons-io:2.5'
How come collections doesn't have CircularFifoBuffer ? I can't find it. Same goes to BufferUtils
|
8

Place the jar file in the libs folder in the root of your module. Then File -> Project Settings. In the left side choose the module where you want to add this lib, in the right side choose tab Dependencies. In the bottom press Plus sign and click File dependency. Then choose your jar and sync project

12 Comments

Is there a way to do this just by placing some text in Gradle and having to deal with jar files and modules?
@J.K. you mean simply drop jars and not specifying each jar?
No, I mean not dropping any jars, just telling gradle what repo to get them from
Try 'compile 'org.apache.commons:commons-collections4:4.0'
on pressing plus sign another option is Library dependency and there is search - type the name and search for the library you interested in
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.