Android的Proguard的不删除所有日志消息消息、日志、Android、Proguard

2023-09-05 06:28:22 作者:花开花落三生缘

我想创建一个模糊的android应用。我使用ProGuard的为。我想自动删除所有日志。*的消息。我该怎么办呢?我发现this职位,但我仍然得到他们。 (我用一个反编译器检查混淆) ProGuard的-project.txt如下:

I want to create an obfuscated android application. I use ProGuard for that. I would like to automatically remove all the Log.* messages. How can I do that? I found this post but I still get them. (I use a decompiler to check the obfuscation). The proguard-project.txt is the following:

-injars       libs/In.jar
-outjars      libs/Out.jar
#-libraryjars  <java.home>/lib/rt.jar
-libraryjars C:/Users/thomas/android-sdks/platforms/android-7/android.jar

-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
                SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

-keep public class * {
    public protected *;
}

-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** e(...);
}

任何帮助将是AP preciated。 谢谢你。

Any help would be appreciated. Thanks.

推荐答案

这只是删除所有调试 Log.d(TAG,...); 和错误 Log.e(TAG,...)调用:

This only remove all debug Log.d(TAG, "..."); and error Log.e(TAG, "...") calls:

-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** e(...);
}

要删除所有日志调用,只需使用这样的:

To remove all log calls, simply use this:

-assumenosideeffects class android.util.Log { *; }