3

I am trying to upload the files using SFTP from android device using jcraft's jsch library. In debug mode of application the process works absolutely fine, and I'm able to upload the files properly. But when I build application in release mode, jsch library is throwing following exception.

01-08 11:48:00.905 8083-8182/? W/System.err: b.c.a.c0: java.lang.ClassNotFoundException: com.jcraft.jsch.jce.Random
01-08 11:48:00.905 8083-8182/? W/System.err:     at b.c.a.d1.a()
01-08 11:48:00.905 8083-8182/? W/System.err:     at b.c.a.d1.a()
01-08 11:48:00.905 8083-8182/? W/System.err:     at b.d.b.i.b.a()
01-08 11:48:00.905 8083-8182/? W/System.err:     at b.d.b.i.b.doInBackground()
01-08 11:48:00.906 8083-8182/? W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:292)
01-08 11:48:00.906 8083-8182/? W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-08 11:48:00.906 8083-8182/? W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
01-08 11:48:00.906 8083-8182/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
01-08 11:48:00.906 8083-8182/? W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
01-08 11:48:00.906 8083-8182/? W/System.err:     at java.lang.Thread.run(Thread.java:818)
01-08 11:48:00.906 8083-8182/? W/System.err: Caused by: java.lang.ClassNotFoundException: com.jcraft.jsch.jce.Random
01-08 11:48:00.907 8083-8182/? W/System.err:     at java.lang.Class.classForName(Native Method)
01-08 11:48:00.907 8083-8182/? W/System.err:     at java.lang.Class.forName(Class.java:309)
01-08 11:48:00.907 8083-8182/? W/System.err:     at java.lang.Class.forName(Class.java:273)
01-08 11:48:00.907 8083-8182/? W/System.err:    ... 10 more
01-08 11:48:00.907 8083-8182/? W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.jcraft.jsch.jce.Random" on path: DexPathList[[zip file "/data/app/com.spirituspay.spaycardapplication-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
01-08 11:48:00.908 8083-8182/? W/System.err:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
01-08 11:48:00.908 8083-8182/? W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-08 11:48:00.908 8083-8182/? W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
01-08 11:48:00.908 8083-8182/? W/System.err:    ... 13 more
01-08 11:48:00.908 8083-8182/? W/System.err:    Suppressed: java.lang.ClassNotFoundException: com.jcraft.jsch.jce.Random
01-08 11:48:00.908 8083-8182/? W/System.err:     at java.lang.Class.classForName(Native Method)
01-08 11:48:00.908 8083-8182/? W/System.err:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
01-08 11:48:00.908 8083-8182/? W/System.err:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
01-08 11:48:00.908 8083-8182/? W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
01-08 11:48:00.908 8083-8182/? W/System.err:        ... 14 more
01-08 11:48:00.908 8083-8182/? W/System.err:    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available'

I have tried replacing gradle library with local JAR, also tried by disabling the proGuard rules in release mode.

What else might be the cause of this?

Please let me know if you need any other information for diagnostic.

Kiran Malvi
  • 636
  • 2
  • 9
  • 29

1 Answers1

1

add to proguard-rules.pro: -keep class com.jcraft.jsch.** { *; }

Andrew Glukhoff
  • 898
  • 11
  • 9