diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 2bea197..e868a0b 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -192,4 +192,7 @@ dependencies {
// leakcanary
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.7")
+
+ // Startup
+ implementation("androidx.startup:startup-runtime:1.1.0")
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2a16ae2..576c956 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,5 +1,6 @@
@@ -28,6 +29,16 @@
+
+
+
+
diff --git a/app/src/main/kotlin/com/mohsenoid/rickandmorty/RickAndMortyApplication.kt b/app/src/main/kotlin/com/mohsenoid/rickandmorty/RickAndMortyApplication.kt
index c0ec60c..682f6a1 100644
--- a/app/src/main/kotlin/com/mohsenoid/rickandmorty/RickAndMortyApplication.kt
+++ b/app/src/main/kotlin/com/mohsenoid/rickandmorty/RickAndMortyApplication.kt
@@ -7,7 +7,6 @@ import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.component.KoinComponent
import org.koin.core.context.startKoin
-import timber.log.Timber
class RickAndMortyApplication : MultiDexApplication(), KoinComponent {
@@ -16,8 +15,6 @@ class RickAndMortyApplication : MultiDexApplication(), KoinComponent {
override fun onCreate() {
super.onCreate()
- if (isDebug) setupTimber()
-
startKoin {
val appProperties: Map = mapOf(
KoinQualifiersNames.BASE_URL to BuildConfig.BASE_URL,
@@ -30,15 +27,4 @@ class RickAndMortyApplication : MultiDexApplication(), KoinComponent {
modules(appModule + dataModule)
}
}
-
- private fun setupTimber() {
- Timber.plant(
- object : Timber.DebugTree() {
- override fun createStackElementTag(element: StackTraceElement): String {
- // adding file name and line number link to logs
- return "${super.createStackElementTag(element)}(${element.fileName}:${element.lineNumber})"
- }
- },
- )
- }
}
diff --git a/app/src/main/kotlin/com/mohsenoid/rickandmorty/startup/TimberInitializer.kt b/app/src/main/kotlin/com/mohsenoid/rickandmorty/startup/TimberInitializer.kt
new file mode 100644
index 0000000..1927ffe
--- /dev/null
+++ b/app/src/main/kotlin/com/mohsenoid/rickandmorty/startup/TimberInitializer.kt
@@ -0,0 +1,28 @@
+package com.mohsenoid.rickandmorty.startup
+
+import android.content.Context
+import androidx.startup.Initializer
+import com.mohsenoid.rickandmorty.BuildConfig
+import timber.log.Timber
+
+class TimberInitializer : Initializer {
+
+ private val isDebug: Boolean = BuildConfig.DEBUG
+
+ override fun create(context: Context) {
+ if (isDebug) setupTimber()
+ }
+
+ private fun setupTimber() {
+ Timber.plant(
+ object : Timber.DebugTree() {
+ override fun createStackElementTag(element: StackTraceElement): String {
+ // adding file name and line number link to logs
+ return "${super.createStackElementTag(element)}(${element.fileName}:${element.lineNumber})"
+ }
+ },
+ )
+ }
+
+ override fun dependencies(): MutableList>> = mutableListOf()
+}