2017-12-30 54 views
0

私はproguardのルールで以下のコードを使用してlog.dを取り除きました。リリースapkをコンパイルする前に残っていたかもしれません。私のAPKから木材ログを取り除く

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

すべての木材ログには方法がありますか?

Timber.w("This shouldn't show in release apk when decompiled"); 

答えて

0

は同じアプローチを考え - しかしTimberクラスを使用する代わりにLog - 動作しませんか?例えば:

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

また、あなたがsample projectに従うと、何か行うことができます:

public class App extends Application { 
    @Override 
    public void onCreate() { 
    super.onCreate(); 

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

    private static class ProductionTree extends Timber.Tree { 
    @Override 
    protected void log(int priority, String tag, String message, Throwable t) { 
     // Do whatever (or nothing) here. 
    } 
    } 
} 
+0

ProGuardのコードが働いていたが。 推奨されていた2番目のアプローチは、コードを実際には削除せず、実装を変更するだけです。 – RJFares

関連する問題