I found the code below on the B4J side, at the link below:
https://www.b4x.com/android/forum/threads/decode-email-body-solved.53830/
I want to use this code to decode base64 in a B4A project. I see the notation that it requires Java 8. I have java 8 installed, yet I get the error - java.lang.ClassNotFoundException: java$util$Base64. I’m not sure whether this means B4A doesn’t know Base64, or if there is something wrong with my B4A Paths. It seems odd that B4J passes this code while B4A does not.
My Paths Configuration and the Error Log are attached. Is there something in my Paths Configuration that should be changed? Any help greatly appreciated.
https://www.b4x.com/android/forum/threads/decode-email-body-solved.53830/
I want to use this code to decode base64 in a B4A project. I see the notation that it requires Java 8. I have java 8 installed, yet I get the error - java.lang.ClassNotFoundException: java$util$Base64. I’m not sure whether this means B4A doesn’t know Base64, or if there is something wrong with my B4A Paths. It seems odd that B4J passes this code while B4A does not.
My Paths Configuration and the Error Log are attached. Is there something in my Paths Configuration that should be changed? Any help greatly appreciated.
B4X:
Sub DecodeB64(Mess As String)
jo.InitializeStatic("java.util.Base64")
decoder = jo.RunMethod("getMimeDecoder", Null)
buf = decoder.RunMethod("decode", Array(Mess))
Dim news As String
For Each c As Byte In buf
news = news & Chr(c)
Next
Log("DECODED = : "&news) 'Decoded Message!
End Sub
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 4754 (Main)
java.lang.ClassNotFoundException: java$util$Base64
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at java.lang.Class.forName(Class.java:273)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:273)
at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:74)
at mail.purge.whapp.main._decodeb64(main.java:6940)
at mail.purge.whapp.main._pop_downloadcompleted(main.java:10919)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA$2.run(BA.java:328)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java$util$Base64" on path: DexPathList[[zip file "/data/app/mail.purge.whapp-3/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 24 more
Suppressed: java.lang.ClassNotFoundException: java$util$Base64
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 25 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
** Activity (main) Pause, UserClosed = true **