I have the following statement in my proguard-rules.pro
to strip out logging in the production apk:
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
This has the effect of removing statements like:
Log.d(TAG, "setup finished");
Now let's consider the following statement:
Log.d(TAG, "setup finished with status " + client.getStatus());
My assumption until now was that this Log.d()
statement would be stripped out and therefore that client.getStatus()
would never get called.
Specifically, if client
happens to be null
then my assumption had been that there would be no NullPointerException
.
But now I'm not so sure. Perhaps the compiler looks at the above statement more like the following:
int status = client.getStatus();
Log.d(TAG, "setup finished with status " + status);
Now the client.getStatus()
statement is executed and NullPointerException
may result.
What is the actual situation?
Note: I'm actually now using R8 rather than ProGuard.