Add dependency to build.gradle:
dependencies {
implementation ...
implementation "com.jakewharton.timber:timber:4.7.1" // Update version if necessary
}
Build an application class (a base class that contains global application state for your entire app):
class PusherApplication: Application() {
override fun onCreate() {
Timber.plant(Timber.DebugTree())
super.onCreate()
}
}
Register the application in AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.dessertpusher">
<application
android:allowBackup="true"
...
android:name=".PusherApplication"> // <- Here!
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Use Timber.x instead of Log.x when calling logs
