Klog的使用

1.添加依赖

implementation 'com.github.zhaokaiqiang.klog:library:1.6.0'

2.配置文件

  buildTypes {

        debug{
            buildConfigField "boolean", "LOG_DEBUG", "true"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            buildConfigField "boolean", "LOG_DEBUG", "true"
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

如需release版本不打印日志,只需要将release下面的true改成false即可。
3.在application中初始化。

public class App extends Application {
    private static App mApp;

    public static Application getInstance() {
        return mApp;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mApp = this;
        KLog.init(BuildConfig.LOG_DEBUG, "Kai");
        //讯飞
        SpeechUtility.createUtility(this, SpeechConstant.APPID + "=5b967215");
    }
}

你可能感兴趣的:(Android基础知识)