Using this test code in a class:
everything works fine when the two called subs exist.
If the sub in Main doesn't exist then it is ignored (no action taken). This is so in debug, release and release(obfuscated) modes. That's fine, I can work with that.
However if the sub in the class doesn't exist there is a problem:
In debug the code works as expected and the lines in 'catch' are executed.
However in release and release(obfuscated) the program crashes:
Is there any way to handle this situation without the crash? Note: the called sub doesn't exist so it can't be handled there.
It's not practical to " just make sure the sub does exist" due to the way the real App works.
Thanks
B4X:
public Sub TestCall(TestSubString As String)
Try
Log("Calling sub in Main")
CallSub(Main, TestSubString & "_Data")
Log("Calling sub in Class")
CallSub(Me, TestSubString & "_Data")
Catch
Log("Catch")
Log(LastException)
End Try
End Sub
Sub Refresh_Data
Log("------------> Class Refresh data")
End Sub
If the sub in Main doesn't exist then it is ignored (no action taken). This is so in debug, release and release(obfuscated) modes. That's fine, I can work with that.
However if the sub in the class doesn't exist there is a problem:
In debug the code works as expected and the lines in 'catch' are executed.
However in release and release(obfuscated) the program crashes:
B4X:
Calling sub in Class
test_v5 (java line: 51)
java.lang.Exception: Sub refresh_data was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:202)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:1030)
at b4a.example.test._v5(test.java:51)
at b4a.example.main._b_click(main.java:369)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6311)
at android.view.View$PerformClick.run(View.java:24996)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6537)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
It's not practical to " just make sure the sub does exist" due to the way the real App works.
Thanks