Android Question [Solved] [B4xPages] Sub does not exist when compiled in release obfuscated

marcick

Well-Known Member
Licensed User
Longtime User
Hi all,
I’m writing a class that performs callbacks to the calling page, but the callbacks don’t work.
To understand where the problem is, I did several tests. I discovered that the callback sub is considered as not existing, even when I check it directly inside the page where it is defined.
For example, inside the page that contains the sub, this returns False:

B4X:
Private Sub B4XPage_Appear
    Log("EXISTS: " & SubExists(Me, "Test"))
End Sub

Private Sub Test
    log("Test")
End Sub

logged: EXISTS: false

This happens only when compiling in Release Obfuscated.
In Debug and Release (not obfuscated) it works correctly.

I’m using B4A 13.40.

Am I doing something wrong?
 

marcick

Well-Known Member
Licensed User
Longtime User
Thanks guys, I was going crazy over this 😅
I didn’t realize that, with obfuscation enabled, subs without an underscore can be renamed and therefore can’t be found via SubExists / CallSub*.
Adding an underscore to the callback sub name fixed the issue completely.


Really appreciate the clarification!
 
Upvote 0
Top