Hong
Hong

Reputation: 18531

Error "java.lang.NoClassDefFoundError: com.google.repacked.apache.commons.io.FileUtils"

An Android app has the following in its build.gradle:

dependencies {
    ...
    compile 'commons-io:commons-io:2.4'
}

Building and installing the app has no problem. However the following code:

FileUtils.writeStringToFile(fText, "Test");

causes the the following exception:

java.lang.NoClassDefFoundError: com.google.repacked.apache.commons.io.FileUtils

Could anyone offer a tip on how to remedy this?

[Edit:]

I have just realized the app can still be built without the following in build.gradle:

dependencies {
    ...
    compile 'commons-io:commons-io:2.4'
}

FileUtils is the following: enter image description here

Could anyone tell what com.google.repacked is and how to get rid of it?

Upvotes: 4

Views: 565

Answers (1)

Eric B.
Eric B.

Reputation: 24481

Quick guess, but it doesn't seem like you are using FileUtils from the commons lib. Double check your import statement to see where FileUtils is imported from.

Ensure that you are importing the org.apache...FileUtils class and not something from the com.google... package.

Upvotes: 1

Related Questions