Ammad
Ammad

Reputation: 21

java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.readFileToByteArray

Method readFileToByteArray(File file) is present in imported jar file in android project.

enter image description here

But still getting this error at runtime when try to test the project:

java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.readFileToByteArray
    at com.googlecode.dex2jar.reader.DexFileReader.<init>(DexFileReader.java:240)
    at com.example.dex2jar.MainActivity.dextojar(MainActivity.java:67)
    at com.example.dex2jar.MainActivity.onCreate(MainActivity.java:88)
    at android.app.Activity.performCreate(Activity.java:5231)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    at dalvik.system.NativeStart.main(Native Method)

Upvotes: 1

Views: 2544

Answers (1)

Adam
Adam

Reputation: 2269

You probably need to explictly declare the version of commons-io you want to use. Something like this: compile group: 'commons-io', name: 'commons-io', version: '2.5'.

Most likely, some other dependency is pulling in the wrong version of commons-io at runtime, which is why you are seeing that error only when you actually run your app.

Upvotes: 4

Related Questions