4

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?

Hong
  • 15,059
  • 14
  • 64
  • 105
  • 1
    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. – Eric B. May 14 '16 at 02:10
  • @EricB. You are spot on. It use import com.google.repacked.apache.commons.io.FileUtils; As I asked in my new edit, what is com.google.repacked? It looks like a legitimate thing, but does not work. – Hong May 14 '16 at 02:16
  • 1
    I have no idea what that package is. My guess would be the commons-io repackaged by Google and included in some base Android libs. For your issue, just mark the import as org.apache...FileUtils – Eric B. May 14 '16 at 02:18
  • @EricB. Could you turn your comment into a answer so that I can accept it? – Hong May 14 '16 at 02:20

1 Answers1

1

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.

Eric B.
  • 20,257
  • 43
  • 147
  • 269