从1方法中剥离无效的本地信息 - Proguard

Ege*_*glu 6 android proguard android-proguard

之后我收到了这个警告gradle build.我认为这与我Proguard rules和我有关Logs.我怎样才能"删除无效的当地人信息"?

我想将我的Log包装到LogUtil类:

public class LogUtils {
    public static void debug(final String tag, String message) {
        if (BuildConfig.DEBUG) {
            Log.d(tag, message);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

并将其添加到proguard规则

-assumenosideeffects class android.util.Log {
    public static *** d(...);
}
Run Code Online (Sandbox Code Playgroud)

是一个很好的解决方案,但我的项目中有很多Log.d,所以这很难.

与木材相同的问题.我认为转换为时已晚

if (BuildConfig.DEBUG) {
  Timber.plant(new Timber.DebugTree());
}
Run Code Online (Sandbox Code Playgroud)

Ege*_*glu 2

好的,我已经解决了这个问题:

-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(...);
}
Run Code Online (Sandbox Code Playgroud)