christopherney / Enigma

Gradle Plugin - Obfuscator String Encryption (Android/Java)
MIT License
159 stars 25 forks source link

Illegal Forward Reference #19

Open barkatthemoon18 opened 3 years ago

barkatthemoon18 commented 3 years ago

Greetings.

First off, great work! I started using enigma to obfuscate Strings and it worked perfectly so far, but when I use static initializer to load native library (NDK) it fails with the title's name. Is there any way to prevent Enigma from obfuscate that static initializer without excluding the whole code, or obfuscate it as well?

Example error:

public class A {
  static { 
    System.loadLibrary("somelib"); <- Illegal Forward Reference
  }
}

Appreciate any guidance or help.

Thanks!

christopherney commented 3 years ago

Hi,

You can ignore the class with the JNI call by using the falling option:

enigma​.​ignoredClasses ​=​ [​"​com.your.package-name.A.java​"​]
obirawa commented 3 years ago

As a workaround, put the String as a constant in a dedicated class and add that class to the ignored classes