Skip to content

Commit e031b79

Browse files
committed
Integrated hilt.
Added application class
1 parent 39caa4a commit e031b79

File tree

6 files changed

+34
-13
lines changed

6 files changed

+34
-13
lines changed

app/build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id("com.android.application")
33
id("org.jetbrains.kotlin.android")
4+
kotlin("kapt")
5+
id("com.google.dagger.hilt.android")
46
}
57

68
android {
@@ -37,7 +39,7 @@ android {
3739
compose = true
3840
}
3941
composeOptions {
40-
kotlinCompilerExtensionVersion = "1.1.1"
42+
kotlinCompilerExtensionVersion = ytemplate.android.build.BuildPlugins.COMPOSE_COMPILER
4143
}
4244
packagingOptions {
4345
resources {
@@ -55,6 +57,12 @@ dependencies {
5557
implementation (androidLib.COMPOSE_UI)
5658
implementation (androidLib.COMPOSE_PREVIEW)
5759
implementation (androidLib.COMPOSE_MATERIAL)
60+
implementation(androidLib.COMPOSE_VIEW_MODEL)
61+
implementation(androidLib.COMPOSE_NAV)
62+
implementation(androidLib.HILT_ANDROID)
63+
kapt(androidLib.HILT_COMPILER)
64+
implementation(androidLib.HILT_NAV_COMPOSE)
65+
5866
testImplementation (testLib.JUNIT)
5967
androidTestImplementation (androidLib.JUNIT_ANDROID)
6068
androidTestImplementation (androidLib.ESPRESSO_TEST)

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
android:label="@string/app_name"
1111
android:roundIcon="@mipmap/ic_launcher_round"
1212
android:supportsRtl="true"
13+
android:name="ytemplate.android.YTemplateApp"
1314
android:theme="@style/Theme.YTemplate"
1415
tools:targetApi="31">
1516
<activity
16-
android:name=".MainActivity"
17+
android:name="ytemplate.android.MainActivity"
1718
android:exported="true"
18-
android:label="@string/app_name"
1919
android:theme="@style/Theme.YTemplate">
2020
<intent-filter>
2121
<action android:name="android.intent.action.MAIN" />

app/src/main/java/ytemplate/android/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import androidx.compose.material.Text
1010
import androidx.compose.runtime.Composable
1111
import androidx.compose.ui.Modifier
1212
import androidx.compose.ui.tooling.preview.Preview
13+
import dagger.hilt.android.AndroidEntryPoint
1314
import ytemplate.android.ui.theme.YTemplateTheme
1415

16+
@AndroidEntryPoint
1517
class MainActivity : ComponentActivity() {
1618
override fun onCreate(savedInstanceState: Bundle?) {
1719
super.onCreate(savedInstanceState)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package ytemplate.android
22

33
import android.app.Application
4+
import dagger.hilt.android.HiltAndroidApp
45

6+
@HiltAndroidApp
57
class YTemplateApp : Application(){
68

79
}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ plugins {
33
id ("com.android.application") version buildVersion.PLUGIN_VERSION apply false
44
id ("com.android.library") version buildVersion.PLUGIN_VERSION apply false
55
id ("org.jetbrains.kotlin.android") version buildVersion.KOTLIN_VERSION apply false
6+
id("com.google.dagger.hilt.android") version buildVersion.HILT_PLUGIN apply false
67
}

buildSrc/src/main/java/ytemplate/android/build/Dependencies.kt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,42 @@ package ytemplate.android.build
22

33

44
object BuildPlugins {
5-
const val KOTLIN_VERSION = "1.6.10"
6-
const val PLUGIN_VERSION = "7.3.0"
5+
const val KOTLIN_VERSION = "1.7.20"
6+
const val PLUGIN_VERSION = "7.3.1"
7+
const val HILT_PLUGIN = "2.44"
8+
const val COMPOSE_COMPILER = "1.3.2"
79
}
810

911
object AndroidSdk {
1012
const val MIN_SDK = 26
1113
const val TARGET_SDK = 32
12-
const val COMPILE_SDK = 32
14+
const val COMPILE_SDK = 33
1315
}
1416

1517
object AndroidLib {
1618
private object Version{
17-
const val CORE_KTX = "1.7.0"
18-
const val LIFE_CYCLE_RUNTIME_KTX = "2.3.1"
19-
const val COMPOSE_ACTIVITY="1.3.1"
20-
const val COMPOSE_UI = "1.1.1"
19+
const val CORE_KTX = "1.9.0"
20+
const val ANDROIDX_LIFE_CYCLE = "2.5.1"
21+
const val COMPOSE_ACTIVITY="1.6.1"
22+
const val COMPOSE_UI = "1.3.2"
2123
const val COMPOSE_MATERIAL = "1.1.1"
24+
const val COMPOSE_NAVIGATION = "2.5.3"
2225
const val ANDROID_JUNIT = "1.1.4"
2326
const val ESPRESSO = "3.5.0"
24-
27+
const val HILT = BuildPlugins.HILT_PLUGIN
28+
const val HILT_NAV_COMPOSE = "1.0.0"
2529
}
2630
const val CORE_KTX = "androidx.core:core-ktx:${Version.CORE_KTX}"
27-
const val RUNTIME_KTX = "androidx.lifecycle:lifecycle-runtime-ktx:${Version.LIFE_CYCLE_RUNTIME_KTX}"
31+
const val RUNTIME_KTX = "androidx.lifecycle:lifecycle-runtime-ktx:${Version.ANDROIDX_LIFE_CYCLE}"
2832
const val COMPOSE_ACTIVITY = "androidx.activity:activity-compose:${Version.COMPOSE_ACTIVITY}"
2933
const val COMPOSE_UI = "androidx.compose.ui:ui:${Version.COMPOSE_UI}"
3034
const val COMPOSE_PREVIEW = "androidx.compose.ui:ui-tooling-preview:${Version.COMPOSE_UI}"
3135
const val COMPOSE_MATERIAL = "androidx.compose.material:material:${Version.COMPOSE_MATERIAL}"
32-
36+
const val COMPOSE_VIEW_MODEL = "androidx.lifecycle:lifecycle-viewmodel-compose:${Version.ANDROIDX_LIFE_CYCLE}"
37+
const val COMPOSE_NAV = "androidx.navigation:navigation-compose:${Version.COMPOSE_NAVIGATION}"
38+
const val HILT_ANDROID = "com.google.dagger:hilt-android:${Version.HILT}"
39+
const val HILT_COMPILER = "com.google.dagger:hilt-android-compiler:${Version.HILT}"
40+
const val HILT_NAV_COMPOSE = "androidx.hilt:hilt-navigation-compose:${Version.HILT_NAV_COMPOSE}"
3341
//Android Testing
3442
const val JUNIT_ANDROID = "androidx.test.ext:junit:${Version.ANDROID_JUNIT}"
3543
const val ESPRESSO_TEST = "androidx.test.espresso:espresso-core:${Version.ESPRESSO}"

0 commit comments

Comments
 (0)