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


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: 243
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

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
Like i said something is weird. It does not crash with mine. LOL
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
You should clean the project and retry it
 
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?

Changing String to int fixes the problem
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…