简体   繁体   English

Proguard 不会剥离木材日志

[英]Proguard not stripping down Timber logs

I am using Timber logs for logging in my Android application only in the Debug environment, for that purpose, I added this line in my Application class:-我使用Timber日志仅在调试环境中登录我的 Android 应用程序,为此,我在我的应用程序类中添加了这一行:-

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

I, subsequently, used this throughout my application flawlessly.随后,我在整个应用程序中完美地使用了它。 Also, I obfuscated the Timber logs for release build variant, by adding these lines to my proguard-rules.pro file:-此外,我通过将这些行添加到我的proguard-rules.pro文件中,混淆了用于发布构建变体的 Timber 日志:-

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

In my app's build.gradle , I added this:在我的应用程序的build.gradle ,我添加了以下内容:

release {
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

Despite, all of this in my production app, I got a crash through Crashlytics caused for a NullPointerException inside one of the Timber log statement, the Timber log, first of all, shouldn't have been there in the production app, as I've stripped it down, moreover, I've planted Timber log only in the debug environment, so I don't understand why it'snot stripped down.尽管如此,所有这些都在我的生产应用程序中,我通过 Crashlytics 崩溃了,因为其中一个 Timber 日志语句中出现 NullPointerException,首先,Timber 日志不应该出现在生产应用程序中,因为我已经剥离了它,而且,我只在调试环境中种植了Timber log,所以我不明白为什么它没有被剥离。

I think on Timber has use Log.我认为在 Timber 上使用了 Log。 You can try it add Timber with Log on proguard-rules.pro您可以尝试使用登录 proguard-rules.pro 添加 Timber

# Remove log
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int d(...);
public static int w(...);
public static int v(...);
public static int i(...);
public static int e(...);
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM