如何使用gradle将org.apache.commons.lang3添加到AndroidStudio

Pha*_*hai 54 apache android stringescapeutils gradle

由于这个问题, 我想StringEscapeUntils在包中使用class org.apache.commons.lang3.

但是当我尝试Apache通过添加行compile 'org.apache.commons:commons-collections4:4.0'build.grade文件来导入lib时,则无法导入上面的类.

有没有人可以帮助我如何通过gradle导入上面的项目(不是通过下载.jar并将它们放入项目文件夹).

And*_*eky 169

编辑于07.12.2018:

我认为StringUtils你使用的依赖是不正确的.

请将以下依赖项添加到gradle和Sync项目并导入您的课程.

implementation 'org.apache.commons:commons-lang3:3.6'
Run Code Online (Sandbox Code Playgroud)

这个使用已弃用的任务(但仍然有效):

编译'org.apache.commons:commons-lang3:3.5'

谢谢!

  • 现在已经改为`org.apache.commons:commons-text:1.4` (5认同)
  • 不要使用这个lib.通过使用此lib,在将apk上传到Google Play商店时,它将显示0个支持的设备.而是使用compile'c​​ommons-lang:commons-lang:2.6'.有用. (2认同)

小智 7

对于 StringUtils,您需要在app.gradle 中添加

implementation 'org.apache.commons:commons-text:1.7'
Run Code Online (Sandbox Code Playgroud)


Sma*_*ngh 6

StringEscapeUtils类移动到org.apache.commons:commons-text。包裹。

因为StringEscapeUtils你需要添加'org.apache.commons:commons-text:1.6'依赖。