I’ve just released this game on Play Store (Mr. Frump) and I noticed that the debug logs are still there. I’ve removed all the logs in my scripts but I’m using a few plugins that log stuff as well. I’m trying to disable all logging on release build and getting nowhere.
After 8 hours, I only found that everyone on Unity forums and on SO suggests either calling Debug.Log with in a preprocessor section or stripping Log function calls with ProGuard.
I find that the first approach is naive considering one does not log errors and assertions oneself.
Since I’m a newbie to ProGuard, second approach led me nowhere. My app crashed on launch with every ProGuard configuration I could do and the logs didn’t help either.
Every time something gets logged, frame rate drops. I’m pulling my hair here and I’d appreciate any help possible.
According to the Unity Documentation relating Best Practice you should wrap development-only logging calls in custom methods and decorating that method with the [Conditional] attribute.
#define ENABLE_LOGS
public static class Logger {
[Conditional("ENABLE_LOGS")]
public void Debug(string logMsg) {
Debug.Log(logMsg);
}
}
If none of the defines passed to the
Conditional attribute are defined,
then the decorated method and all calls to the decorated method are compiled out. The effect is
identical to what would happen if the
method and all calls to the method
were wrapped in #if … #endif
preprocessor blocks.
EDIT:
I remembered it was there, but not the correct section.
According to the Unity Documentation, you need to untick the option Use Player Log in Resolution and Presentation
Check this box to write a log file with debugging information. If you plan to submit your application to the Mac App Store, leave this option un-ticked. Ticked is the default.
Maybe try to export into android studio first if your target is android. Then change build variant into release. If it is not solve the issue, try to use custom proguard, in unity 2020, you can check in build settings → custom proguard. For the detail you can check my article here