Android Question Why? java.lang.ClassCastException

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Sorry, this makes no sense to me.

My code is:
Code:
Sub LockoutCheckout( lock As Boolean ) As Boolean
    If lock Then
        If Starter.CheckoutIsLocked Then
            Msgbox("CHECKOUT IS ALREADY RUNNING." & CRLF & CRLF & _
                    "This is a safetey check to protect against" & CRLF & _
                    "double posting of transactions." & CRLF & _
                    "It appears CHECKOUT is ALREADY RUNNING." & CRLF & _
                    "Please give this 30 seconds to complete." & CRLF & CRLF & _
                    "If after 30 seconds you find yourself here again" & CRLF & _
                    "then EXIT the EljayDelivery app" & CRLF & _
                    "(close all windows, or if needed power-off the tablet)" & CRLF & _
                    "then restart the EljayDelivery app" & CRLF & _
                    "and try CHECKOUT again.","CHECKOUT DOUBLE POSTING PROTECTION")
            Return False
        Else
            Starter.CheckoutIsLocked = True
            Return True
        End If
    Else
        Starter.CheckoutIsLocked = False
    End If
    Return False
End Sub

Line 122 is the very LAST "Return False", just before END SUB. The exception I am getting is:

Error occurred on line: 122 (CheckOut)
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
at odp.eljaydelivery.checkout._lockoutcheckout(checkout.java:477)
at odp.eljaydelivery.checkout._transactionsuploaded(checkout.java:1036)
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:708)
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:5376)
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:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

This should be obvious, but not seeing it. Any suggestions would be greatly appreciated.
 
Without seeing all the code it is hard to say, but if it were me I would check the line that is invoking this routine and make sure that you are passing in a Boolean variable and not some other type.
 
Upvote 0
Thank you for giving this a thought Jeffrey. Here are all my references...
Code:
    If Not(LockoutCheckout(True)) Then
        Activity.Finish
         Return
    End If
....
and 4 more references, all like this:
        LockoutCheckout(False)
 
Upvote 0
Thanks again Jeffrey. I've never used the PROJECT CLEAN feature. Not sure what it does, but I've read it is only supposed to be before producing a release APK. But anyway, this mystery seems to have resolved with your suggestion.
 
Upvote 0
Back
Top