Android Question XML to Json, something is missing

rkmoray

Active Member
Licensed User
Longtime User
I am trying to convert an xml file to json for processing. I am following the samples from another threat, and the sample works.
But when I move the code into my app, it fails.
The fail is on the initialize
Dim jo As JavaObject
jo.InitializeNewInstance("org.json.XML",Null) //this is where the fail occurs

My project has JavaObject 2.05, XMLBuilder 1.00, and Json 1.10.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

rkmoray

Active Member
Licensed User
Longtime User
Here is the entire error message:
Error occurred on line: 138 (Main)
java.lang.ClassNotFoundException: org$json$XML
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at java.lang.Class.forName(Class.java:285)
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:273)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:83)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:240)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org$json$XML" on path: DexPathList[[zip file "/data/app/b4a.example-1/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-1/lib/x86_64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 23 more
Suppressed: java.lang.ClassNotFoundException: org$json$XML
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)
... 24 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
 
Upvote 0

rkmoray

Active Member
Licensed User
Longtime User
Thank you for the suggestion.
I already had the reference call in my application, as well,
as the java-json.jar is in the library folder.
Interesting how it does not have an xml file.
But that still does not help me understand why is works in the sample, but not in my code.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I already had the reference call in my application, as well,
do you want to bet on this? I put a "cinemavisit (15$)" in the pot

NO. You did not implement it correctly.
Check your code and check the example.
ONE line is missing. The #additionaljar-line!
 
Upvote 0

rkmoray

Active Member
Licensed User
Longtime User
Here is the sample "
#Region Project Attributes
#ApplicationLabel: JsXl
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#AdditionalJar: Java-Json
#End Region"
and here is my attribute section
"
#Region Project Attributes
#ApplicationLabel: evMobile
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#AdditionalJar: Java-Json
#End Region

#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region"
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Here is the sample
i know the sample-code. I had a look at it.
Again:
You are missing a essential line. I also suggested this (in post #6) to add this line but you told you DID add it (which is not true!).

Tip: search for "additionaljar" in the sample-code
 
Upvote 0

rkmoray

Active Member
Licensed User
Longtime User
I do not understand, in line #8 of my code (as in the previous post) is "#AdditionalJar: Java-Json"
 
Upvote 0

Misterbates

Active Member
Licensed User
There's no path before the jar filename ... Where have you saved your code and where have you saved the example code in relation to the jar file? Is there another copy of the jar file in the example folder that it can find but that your version can't find?
 
Upvote 0

rkmoray

Active Member
Licensed User
Longtime User
It was only in my additional library folder, but I just added as well to my internal library folder. No difference.
I get the same error.
 
Upvote 0
Top