A fully functional Android app built entirely with Kotlin and Jetpack Compose
Add DI scaffolding
Adetunji Dahunsi41874d73efeb
diff --git a/app/build.gradle b/app/build.gradleindex ef403d527..72e25ba6f 100644--- a/app/build.gradle+++ b/app/build.gradle@@ -16,8 +16,10 @@plugins {id 'com.android.application'id 'kotlin-android'+ id 'kotlin-kapt'id 'kotlinx-serialization'id 'jacoco'+ id 'dagger.hilt.android.plugin'}def jacocoTestReport = tasks.create("jacocoTestReport")@@ -133,6 +135,9 @@ dependencies {implementation libs.androidx.compose.runtimeimplementation libs.androidx.compose.runtime.livedata+ implementation libs.hilt.android+ kapt libs.hilt.compiler+debugImplementation libs.androidx.compose.ui.testManifesttestImplementation libs.junit4diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xmlindex 5f61d5605..a73a8f0e5 100644--- a/app/src/main/AndroidManifest.xml+++ b/app/src/main/AndroidManifest.xml@@ -17,6 +17,7 @@package="com.google.samples.apps.nowinandroid"><application+ android:name=".NiAApp"android:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/NiAApp.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/NiAApp.ktnew file mode 100644index 000000000..54d5b24ad--- /dev/null+++ b/app/src/main/java/com/google/samples/apps/nowinandroid/NiAApp.kt@@ -0,0 +1,26 @@+/*+ * Copyright 2021 The Android Open Source Project+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * https://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++package com.google.samples.apps.nowinandroid++import android.app.Application+import dagger.hilt.android.HiltAndroidApp++/**+ * [Application] class for NiA+ */+@HiltAndroidApp+class NiAApp : Application()diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/di/AppModule.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/di/AppModule.ktnew file mode 100644index 000000000..6c88450a6--- /dev/null+++ b/app/src/main/java/com/google/samples/apps/nowinandroid/di/AppModule.kt@@ -0,0 +1,25 @@+/*+ * Copyright 2022 The Android Open Source Project+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * https://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++package com.google.samples.apps.nowinandroid.di++import dagger.Module+import dagger.hilt.InstallIn+import dagger.hilt.components.SingletonComponent++@Module+@InstallIn(SingletonComponent::class)+class AppModulediff --git a/build.gradle b/build.gradleindex d3c73337f..b2d8f4fa8 100644--- a/build.gradle+++ b/build.gradle@@ -33,6 +33,7 @@ buildscript {classpath(libs.android.gradlePlugin)classpath(libs.kotlin.gradlePlugin)classpath(libs.kotlin.serializationPlugin)+ classpath(libs.hilt.gradlePlugin)}}diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex fb590176a..02c977156 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -12,6 +12,7 @@ androidxLifecycle = "2.4.0"androidxNavigation = "2.4.0-rc01"androidxTest = "1.4.0"androidxTestExt = "1.1.2"+hilt = "2.40.5"jacoco = "0.8.7"junit4 = "4.13"kotlin = "1.6.0"@@ -47,6 +48,9 @@ androidx-test-core = { group = "androidx.test", name = "core", version.ref = "anandroidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidxEspresso" }androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidxTest" }androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "androidxTest" }+hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }+hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }+hilt-gradlePlugin = { group = "com.google.dagger", name = "hilt-android-gradle-plugin", version.ref = "hilt" }junit4 = { group = "junit", name = "junit", version.ref = "junit4" }kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }kotlin-serializationPlugin = { group = "org.jetbrains.kotlin", name = "kotlin-serialization", version.ref = "kotlin" }