B4J Question [solved] B4J app obfuscated release and decompilation

aeric

Expert
Licensed User
Longtime User
Today I was wondering after seeing that jar file can be decompiled.
I compile my app with the mode Release (obfuscated) and use a decompiler to check my source.
All the while I know that my variables declared in Process Global sub in Main module will be obfuscated but to my surprise, it is not in my case.
I tried to create a small project and the obfuscation works! I see some of the variables are renamed and changed to some byte values.
So now raise a concern to me, what I have done wrong in my big project that break the obfuscation in B4J. Is it the Conditional symbols or other thing?
 

udg

Expert
Licensed User
Longtime User
Yes, underscores prevent obfuscation

Read here for Erel's tutorial.
 
Upvote 0
Solution

PaulMeuris

Active Member
Licensed User
A B4J testproject where the obfuscation doesn't work:
B4J code:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private btndata As Button
    Private btnreport As Button
    Private ta1 As TextArea
    Private wv1 As WebView
    Private reclst As List
    Private htmlstring As String = ""
    Private itemlst As List
    Private valuesmap As Map
    Private headlst As List
    Private fldlst As List
End Sub
And the decompiled java code:
Java:
public String _class_globals() throws Exception {
    this._vvvv1 = new B4XViewWrapper();
    this._vvvv2 = new B4XViewWrapper.XUI();
    this._btndata = new ButtonWrapper();
    this._btnreport = new ButtonWrapper();
    this._ta1 = new TextInputControlWrapper.TextAreaWrapper();
    this._wv1 = new WebViewWrapper();
    this._vvvv3 = new List();
    this._vvvv4 = "";
    this._vvvv5 = new List();
    this._vvvv6 = new Map();
    this._vvvv7 = new List();
    this._vvvv0 = new List();
    return "";
  }
Conclusion: obfuscation will make it more difficult to read your code but it will not prevent a malicious programmer from stealing your code.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
A B4J testproject where the obfuscation doesn't work:
B4J code:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private btndata As Button
    Private btnreport As Button
    Private ta1 As TextArea
    Private wv1 As WebView
    Private reclst As List
    Private htmlstring As String = ""
    Private itemlst As List
    Private valuesmap As Map
    Private headlst As List
    Private fldlst As List
End Sub
And the decompiled java code:
Java:
public String _class_globals() throws Exception {
    this._vvvv1 = new B4XViewWrapper();
    this._vvvv2 = new B4XViewWrapper.XUI();
    this._btndata = new ButtonWrapper();
    this._btnreport = new ButtonWrapper();
    this._ta1 = new TextInputControlWrapper.TextAreaWrapper();
    this._wv1 = new WebViewWrapper();
    this._vvvv3 = new List();
    this._vvvv4 = "";
    this._vvvv5 = new List();
    this._vvvv6 = new Map();
    this._vvvv7 = new List();
    this._vvvv0 = new List();
    return "";
  }
Conclusion: obfuscation will make it more difficult to read your code but it will not prevent a malicious programmer from stealing your code.
I understand.
 
Upvote 0
Top