Why StringUtils Apache class is not recognized in Android?

You don't say whether you are using Eclipse or Android Studio. In Android Studio, you would add,

import org.apache.commons.lang3.StringUtils;

to your source code file. In build.gradle, you need to change your dependency from something like,

dependencies {
    compile 'com.android.support:support-v4:+'
}

to

dependencies {
    compile 'com.android.support:support-v4:+'
    compile  'org.apache.commons:commons-lang3:3.0'
}

In other words, you would add to the dependency.


Android offers a subset of that functionality in android.text.TextUtils.

Depending on what you need from StringUtils, that might be an option. E.g., it has join, split.


Apache Commons lang is a separate library. You can find it here.

Tags:

Android