minify and obfuscate Java code

Hi, I use Unity 2020.1.0.

I hava 1 Java file (created with Android Studio) under my Scripts folder in Unity. After I build my app my Java file is not obfuscated.

Somewhere I read that I can check ProGuard in Unity to obfuscate my Java file in the build but I can’t find this setting under Player Settings > Publishing Settings

I checked Release and Debug under Minify but that doesn’t work - after build the Java file is missing.

How I can minify and obfuscate my Java file(s)?

Is there a tool for that? Or Unity can do this also?

I see this thread is old enough that you’ve probably solved the issue, but just in case…

If your Java file is missing, it’s probably because the minification process is removing it due to not finding a reachable path to that file from the entry points of your app.

I guess you should use -keep directives in the proguard file or hardcoded @keep annotations, as described here.

1 Like