Following Removing unused strings during ProGuard optimisation I created Logg class that is designed to be easily removed by Proguard:
public class Logg {
public static void e(Object... args) {
Log.e(TAG, buildString(args));
}
public static void d(Object... args) {
Log.d(TAG, buildString(args));
}
}
Next, I added these rules to proguard-rules.pro used by project:
-assumenosideeffects class com.mypackage.Logg {
public static *** d(...);
public static *** e(...);
}
-optimizationpasses 10
After the project is built, I inspect the resulting classes.jar file with JD-GUI and see lines like these:
new Object[1][0] = "Some log message";
The Logg.e(... call is removed but the constant is still there. With -optimizationpasses 5 the line was mentioning String instead of Object.
Is there a way to make sure that Proguard will remove those Strings?