我需要从发布的应用程序类型中删除所有日志记录。我已经尝试配置proguard来为我做。我的配置与此处提供的配置基本匹配:proguard doesn't remove logs。
我已将proguard-android.txt
更改为proguard-android-optimize.txt
,但是没有运气。在浏览完Proguard手册并检查了:
-whyareyoukeeping 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(...);
public static int wtf(...);
}
了解到由于以下原因,无法将其删除:
Explaining why classes and class members are being kept...
Printing usage to [...]...
android.util.Log
is a library class.
android.util.Log: boolean isLoggable(java.lang.String,int)
is a library method.
android.util.Log: int v(java.lang.String,java.lang.String)
is a library method.
android.util.Log: int v(java.lang.String,java.lang.String,java.lang.Throwable)
is a library method.
android.util.Log: int i(java.lang.String,java.lang.String)
is a library method.
android.util.Log: int i(java.lang.String,java.lang.String,java.lang.Throwable)
is a library method.
android.util.Log: int w(java.lang.String,java.lang.String)
is a library method.
android.util.Log: int w(java.lang.String,java.lang.String,java.lang.Throwable)
is a library method.
android.util.Log: int w(java.lang.String,java.lang.Throwable)
is a library method.
android.util.Log: int d(java.lang.String,java.lang.String)
is a library method.
android.util.Log: int d(java.lang.String,java.lang.String,java.lang.Throwable)
is a library method.
android.util.Log: int e(java.lang.String,java.lang.String)
is a library method.
android.util.Log: int e(java.lang.String,java.lang.String,java.lang.Throwable)
is a library method.
android.util.Log: int wtf(java.lang.String,java.lang.String)
is a library method.
android.util.Log: int wtf(java.lang.String,java.lang.Throwable)
is a library method.
android.util.Log: int wtf(java.lang.String,java.lang.String,java.lang.Throwable)
is a library method.
这可能是什么原因?也许还有其他Proguard选项?还有其他选项可以强制删除日志吗?
答案 0 :(得分:0)
您需要指定ProGuard应该使用如下配置删除这些日志记录调用:
-assumenosideeffects class android.util.Log
{
public static int d(...);
public static int v(...);
public static int i(...);
public static int e(...);
}
请记住,您需要启用优化才能实际删除这些呼叫。为此,请使用以下默认配置:
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
答案 1 :(得分:0)
借助Guardsquare的支持,我已经能够找出问题所在。其中一个库的ProGuard配置文件中具有 -dontoptimize 。 -printconfiguration [filename]
有助于缩小此问题的范围文档。供参考-https://www.guardsquare.com/en/products/proguard/manual/usage#generaloptions