XML Parse field code error (Help Please)

giga

Well-Known Member
Licensed User
Longtime User
When I run the xmlSax.

I receive this error:

java.lang.RuntimeException: Field key was declared with the wrong type.


Code:
Sub sync_EndElement (Uri As String, Name As String, Text As StringBuilder)
 
If parser.Parents.IndexOf("maps") > -1 Then
   If Name = "user" Then      ' the element is user
   profi = Text.ToString        ' the attribute is profi
Else If Name = "timestamp" Then    ' the element is timestamp
   time = Text.ToString         ' the attribute is profi
Else If Name = "port" Then               ' the element is port
   number = Text.ToString     ' the attribute is number

End If
End If
If Name = "maps" Then
File.WriteString(DirName, FileName6, Text)
Log(Text.ToString)
End If

This is what the xml file looks like from XMLBuilder

<?xml version="1.0" encoding="UTF-8"?>
-<maps>
<user profi="bob"/>
<timestamp time="date"/>
<port number="80"/>
</maps>

Could this be a problem in the xml file or the code.

Thanks as always
 
Last edited:
Please run your code in Debug mode and then post the full error message from the logs.

Erel,

1. In debug mode, It is pausing on this Activity.LoadLayout("Advanced")

Code:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
Activity.LoadLayout("Advanced")

2. then I hit the play arrow and i get the error below error.


Log file content:

LogCat connected to: emulator-5554
** Activity (advanced) Create, isFirst = true **
advanced_activity_create (B4A line: 44)
Activity.LoadLayout("Advanced")
java.lang.RuntimeException: java.lang.RuntimeException: Field key was declared with the wrong type.
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:140)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:184)
at gigabyte.backup.advanced._activity_create(advanced.java:279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at gigabyte.backup.advanced.afterFirstLayout(advanced.java:84)
at gigabyte.backup.advanced.access$100(advanced.java:16)
at gigabyte.backup.advanced$WaitForLayout.run(advanced.java:72)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Field key was declared with the wrong type.
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:242)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:266)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123)
... 17 more
java.lang.RuntimeException: java.lang.RuntimeException: Field key was declared with the wrong type.

Thanks for the help Erel.
 
Upvote 0
Back
Top