「Android/kotlin/timber」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→debugをtrueにする方法) |
(→debugをtrueにする方法) |
||
| 行23: | 行23: | ||
参考:https://stackoverflow.com/questions/51235941/timber-not-logging-in-kotlin-android | 参考:https://stackoverflow.com/questions/51235941/timber-not-logging-in-kotlin-android | ||
| − | == | + | ==BuildConfig.DEBUGをtrueにする方法== |
app/build.gradle | app/build.gradle | ||
<pre> | <pre> | ||
| 行32: | 行32: | ||
} | } | ||
</pre> | </pre> | ||
| + | timber.logのBuildConfigを見てる場合は、app側のBuildConfigを見るようにする。 | ||
2021年1月14日 (木) 13:18時点における版
サンプル
app/build.gradle
dependencies {
implementation 'com.jakewharton.timber:timber:4.5.1'
}
MainActivity.kt
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
Timber.e("error!!!")
Timber.i("info!!!")
出力
E/MainActivity: error!!! I/MainActivity: info!!!
参考:https://stackoverflow.com/questions/51235941/timber-not-logging-in-kotlin-android
BuildConfig.DEBUGをtrueにする方法
app/build.gradle
buildTypes {
release {
debuggable true
}
}
timber.logのBuildConfigを見てる場合は、app側のBuildConfigを見るようにする。
