Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add org.apache.commons.lang3 to AndroidStudio with gradle

Due to this question I want to use class StringEscapeUntils in package org.apache.commons.lang3.

But when I try to import Apache lib by add line compile 'org.apache.commons:commons-collections4:4.0' to build.grade file then can not import the class above.

Is there any one can help me how to import above one to my project via gradle (not by download .jar and put them into project folder).

like image 441
ThaiPD Avatar asked Sep 29 '15 03:09

ThaiPD


People also ask

What is Apache Commons lang3?

Description. org.apache.commons.lang3. Provides highly reusable static utility methods, chiefly concerned with adding value to the java. lang classes.

Where do gradle dependencies go?

Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file).


1 Answers

Edited 07.12.2018:

I think dependency for StringUtils you are using is not proper.

Please add below dependency to gradle and Sync project and import your class.

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

This on is using deprecated task (but should still works):

compile 'org.apache.commons:commons-lang3:3.5'

Edit:

As OoDeLally mentioned in a comment,

Above mentioned version is deprecated, Please use below dependency:

implementation 'org.apache.commons:commons-text:1.6' 

Edit 2:

deprecated as for July 2019. Use stackoverflow.com/a/55567755/1541141 instead

Thanks @OoDeLally!

like image 135
AndiGeeky Avatar answered Oct 09 '22 10:10

AndiGeeky