Hello everyone, my app has been getting this weird crash sometimes and I haven't been able to find the cause or when it happens, it happens randomly
does anyone know how to solve it? Also, the crash does not after immediately after the RewardedVideoAd_ReceiveAd and sleep.
B4X:
RewardedVideoAd_ReceiveAd
sending message to waiting queue (sleep)
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String
at anywheresoftware.b4a.keywords.Common$12.run(Common.java:1215)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1226)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8751)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String
at anywheresoftware.b4a.keywords.Common.getComponentBA(Common.java:1252)
at anywheresoftware.b4a.keywords.Common$12.run(Common.java:1158)
... 9 more
From poking around in Core.jar it looks like the error is arising during the processing of a CallSubDelayed call. The CallSubDelayed has posted a Runnable to the message queue and the error occurs when the message queue dispatches that Runnable. I can't say anymore than that as the Runnable code is wrapped in a Try-Catch block and the line 'Common.java:1215' is throwing the exception in the catch block.
It's only a guess, and maybe not a good one, but perhaps one of the arguments to the Sub being called is passed an Object when it should be a String.
Further examination shows the error occurs when the Component parameter of the CallSubdelayed is being cast to a String
1252: c = Class.forName(String.valueOf(BA.packageName) + "." + ((String)Component).toLowerCase(BA.cul));
This occurs when the Component is neither a Class instance nor a BAClass instance in which case it is assumed to be a String. Check your Component parameters.
Btw, I have done this before by forgetting to quote the method parameter of the CallSubdelayed. I don't think it throws an error in the IDE, just a warning about automatic string conversion. When you run the code though, boom...
I have checked my code but still can't find the issue.
I suspect it's an error from a library but I haven't been able to figure out which since I can't see the full error.
It's frustrating lol.. if anyone has another suggestion of how I can find the cause, please suggest it.