如何使用ProGuard剥离Timber.tag。(…).d(…)格式的日志?

问题描述 投票:0回答:1

我需要在生产版本中精简所有木材日志。我在proguard-project.txt中添加了以下内容:

-assumenosideeffects class timber.log.Timber* {
        public static *** tag(...);
        public static *** v(...);
        public static *** i(...);
        public static *** w(...);
        public static *** d(...);
        public static *** e(...);

-assumenosideeffects class timber.log.Timber.tag* {*;}
}

但是仅清除格式为Timber.e()Timber.i()等的日志。带有Timber.tag(..).i(...)的日志不会被剥离。

有什么方法可以实现这一目标?谢谢

android android-studio proguard timber-android
1个回答
0
投票

做一行事情会不会更容易

if (BuildConfig.DEBUG) {
  Timber.plant(Timber.DebugTree())
}

在您的Application子类中?这样,您将只在调试中记录日志

© www.soinside.com 2019 - 2024. All rights reserved.