Bug? Process_Globals Array Crash

Bryanne Vega

Member
Licensed User
Longtime User
Only happens when I have the following on Process Global and running as release or release(obfuscated), if it's on debug it wont happen.

B4X:
Sub Process_Globals
   Dim thisVar(1) As String = Array("Var")
End Sub

B4X:
maininitializeProcessGlobals (java line: 381)
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
    at com.atomicalsoftwares.handheld.main.initializeProcessGlobals(main.java:381)
    at com.atomicalsoftwares.handheld.main.afterFirstLayout(main.java:98)
    at com.atomicalsoftwares.handheld.main.access$000(main.java:17)
    at com.atomicalsoftwares.handheld.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5057)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
    at com.atomicalsoftwares.handheld.main._process_globals(main.java:387)
    at com.atomicalsoftwares.handheld.main.initializeProcessGlobals(main.java:373)
    ... 12 more
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Then don't put the assignment in Process_Globals. You should also not assign an Array of Objects to an Array of Strings. Generally speaking, it's not a great idea to "do stuff" in Process_Globals. Sometimes you can get away with it but it's really just for declaring variables.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…