Android Question Strange Behavior with crashing

Scantech

Well-Known Member
Licensed User
Longtime User
B4X:
CallSub2(Main, "ProcessOBDData_SelfTestMessage", FilterType)

B4X:
Sub ProcessOBDData_SelfTestMessage(FilterType As String)
    'Remove Self Test Message
    If FilterType = 602 Then                 'FORD SELF TEST MESSAGE
        If lstView(VP.CurrentPage).GetSize >= 2 Then lstView(VP.CurrentPage).RemoveAt(1)
    End If
End Sub

====Timer_RequestOBD: Mode1===============
CheckOBDModeAll: Main.Attempt 1
CheckOBDModeAll: SendOBDData 010C
====Timer_RequestOBD: Mode3===============
CheckOBDModeAll: Main.Attempt 1
CheckOBDModeAll: SendOBDData 03
CheckOBDModeAll: Datarecieved 486B10430440000000004A
>
ProcessOBDData: Ret - 0
Error occurred on line: 1645 (Communication)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1056)
at scantech.cardiagnosticpro.communication._processobddata(communication.java:2765)
at scantech.cardiagnosticpro.communication._checkobdmodeall(communication.java:5192)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at scantech.cardiagnosticpro.communication._requestobdgeneric(communication.java:13916)
at scantech.cardiagnosticpro.communication._timer_requestobd_tick(communication.java:17674)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.RuntimeException: java.lang.Exception: Sub ProcessOBDData_SelfTestMessage signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 27 more
Caused by: java.lang.Exception: Sub ProcessOBDData_SelfTestMessage signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:321)
... 28 more

This had me pulling my hair. It crashes only with my large project. I test the code above with new project and will not duplicate the error. I can correct it by adding a return line below it or add logs. Weird stuff happening.
 

Scantech

Well-Known Member
Licensed User
Longtime User
At first i thought it was related to the service name (Communication) then i renamed it but still an error.

I think we need a new version for this fix. It is probably related to the name of ProcessOBDData_SelfTestMessage depending where the location of the underscore is will cause it to crash. Try Process_OBDDataSelfTestMessage it crashes.

Also unused variable in the sub will not be detected using Underscore and also using same variable name in the sub will cause errors.

See attach
 

Attachments

  • Bug.zip
    9 KB · Views: 234
Last edited:
Upvote 0

XbNnX_507

Active Member
Licensed User
Longtime User
You should try CallSubDelayed2
B4X:
CallSubDelayed2(Main, "ProcessOBDData_SelfTestMessage", FilterType )
 
Upvote 0

XbNnX_507

Active Member
Licensed User
Longtime User
is not a bug in your Testing Service you have:
B4X:
Sub ProcessOBDData(FilterType As Int, Index As Int, DataReceived As String, WhatMode As String, OptByte As String, lData As List)
   CallSub2(Main, "ProcessOBDData_SelfTestMessage", FilterType)
End Sub

FilterType declare as Int

In your Main Activity you have
B4X:
ProcessOBDData_SelfTestMessage(FilterType As String)
FilterType Declare as String

That's why it crashes.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
is not a bug in your Testing Service you have:
B4X:
Sub ProcessOBDData(FilterType As Int, Index As Int, DataReceived As String, WhatMode As String, OptByte As String, lData As List)
   CallSub2(Main, "ProcessOBDData_SelfTestMessage", FilterType)
End Sub

FilterType declare as Int

In your Main Activity you have
B4X:
ProcessOBDData_SelfTestMessage(FilterType As String)
FilterType Declare as String

That's why it crashes.

Leave it the way it was and change ProcessOBDData_SelfTestMessage (remove underscore) to ProcessOBDDataSelfTestMessage and it will not crash. Try it

Its not related to int.
 
Last edited:
Upvote 0

XbNnX_507

Active Member
Licensed User
Longtime User
it does crashes here:
B4X:
java.lang.IllegalArgumentException: method b4a.example.main._processobddataselftestmessage argument 1 has type java.lang.String, got java.lang.Integer
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
it does crashes here:
B4X:
java.lang.IllegalArgumentException: method b4a.example.main._processobddataselftestmessage argument 1 has type java.lang.String, got java.lang.Integer
Like i said something is weird. It does not crash with mine. LOL
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
After cleaning project and removed Underscore it does crash. Why is my error message different then XbNnX?
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (testing) Create ***
Error occurred on line: 30 (Testing)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1056)
at b4a.example.testing._processobddata(testing.java:140)
at b4a.example.testing._service_create(testing.java:163)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at b4a.example.testing.onCreate(testing.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3162)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1550)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.RuntimeException: java.lang.Exception: Sub ProcessOBDDataSelfTestMessage signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 21 more
Caused by: java.lang.Exception: Sub ProcessOBDDataSelfTestMessage signature does not match expected signature.
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:321)
... 22 more
** Service (testing) Start **

Changing String to int fixes the problem
 
Upvote 0
Top