From 763521aabff8744a168a82a804f6f19e5455a04b Mon Sep 17 00:00:00 2001 From: Damontecres <154766448+damontecres@users.noreply.github.com> Date: Sat, 20 Sep 2025 17:42:09 -0400 Subject: [PATCH] Add hilt --- app/build.gradle.kts | 9 +++++---- app/src/main/AndroidManifest.xml | 17 ++++++++++++++++- .../damontecres/dolphin/DolphinApplication.kt | 17 +++++++++++++++++ .../github/damontecres/dolphin/MainActivity.kt | 5 ++++- build.gradle.kts | 4 ++++ gradle/libs.versions.toml | 7 +++++++ settings.gradle.kts | 6 ++++++ 7 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/github/damontecres/dolphin/DolphinApplication.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 60b0c51c..31ed7477 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,9 +1,10 @@ plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) - alias(libs.plugins.kotlin.compose) - alias(libs.plugins.kotlin.plugin.serialization) alias(libs.plugins.protobuf) + alias(libs.plugins.ksp) + alias(libs.plugins.kotlin.compose) + alias(libs.plugins.hilt) } android { @@ -16,7 +17,6 @@ android { targetSdk = 36 versionCode = 1 versionName = "1.0" - } buildTypes { @@ -42,7 +42,6 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) implementation(platform(libs.androidx.compose.bom)) @@ -77,6 +76,8 @@ dependencies { implementation(libs.kotlinx.serialization.core) implementation(libs.kotlinx.serialization.json) + implementation(libs.hilt.android) + ksp(libs.hilt.android.compiler) androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.compose.ui.test.junit4) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 871f2934..6931dcad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,12 +2,26 @@ + + + + + + + + + android:theme="@style/Theme.Dolphin" + android:name=".DolphinApplication"> diff --git a/app/src/main/java/com/github/damontecres/dolphin/DolphinApplication.kt b/app/src/main/java/com/github/damontecres/dolphin/DolphinApplication.kt new file mode 100644 index 00000000..c1cf9714 --- /dev/null +++ b/app/src/main/java/com/github/damontecres/dolphin/DolphinApplication.kt @@ -0,0 +1,17 @@ +package com.github.damontecres.dolphin + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp + +@HiltAndroidApp +class DolphinApplication: Application() { + init { + instance = this + } + + companion object{ + lateinit var instance: DolphinApplication + private set + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/github/damontecres/dolphin/MainActivity.kt b/app/src/main/java/com/github/damontecres/dolphin/MainActivity.kt index 88862c87..7ba1d88d 100644 --- a/app/src/main/java/com/github/damontecres/dolphin/MainActivity.kt +++ b/app/src/main/java/com/github/damontecres/dolphin/MainActivity.kt @@ -3,6 +3,7 @@ package com.github.damontecres.dolphin import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.layout.fillMaxSize import androidx.tv.material3.Text import androidx.compose.runtime.Composable @@ -12,8 +13,10 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.tv.material3.ExperimentalTvMaterial3Api import androidx.tv.material3.Surface import com.github.damontecres.dolphin.ui.theme.DolphinTheme +import dagger.hilt.android.AndroidEntryPoint -class MainActivity : ComponentActivity() { +@AndroidEntryPoint +class MainActivity : AppCompatActivity() { @OptIn(ExperimentalTvMaterial3Api::class) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/build.gradle.kts b/build.gradle.kts index 952b9306..9aa2a38e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,5 +2,9 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.jvm) apply false + alias(libs.plugins.protobuf) apply false + alias(libs.plugins.ksp) apply false alias(libs.plugins.kotlin.compose) apply false + alias(libs.plugins.hilt) apply false } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 437886a3..41b2cd04 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,7 @@ [versions] agp = "8.13.0" kotlin = "2.2.20" +ksp = "2.2.20-2.0.3" coreKtx = "1.17.0" appcompat = "1.7.1" composeBom = "2025.09.00" @@ -19,6 +20,7 @@ datastore = "1.1.7" kotlinx-coroutines-android = "1.10.2" kotlinx-serialization = "1.9.0" protobuf-javalite = "4.32.1" +hilt = "2.57.1" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -35,6 +37,8 @@ androidx-tv-material = { group = "androidx.tv", name = "tv-material", version.re androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } androidx-datastore = { module = "androidx.datastore:datastore", version.ref = "datastore" } +hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" } +hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" } protobuf-kotlin-lite = { module = "com.google.protobuf:protobuf-kotlin-lite", version.ref = "protobuf-javalite" } kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines-android" } kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" } @@ -65,5 +69,8 @@ androidx-material3-adaptive-navigation3 = { group = "androidx.compose.material3. android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } protobuf = { id = "com.google.protobuf", version.ref = "protobuf" } +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 0461f6cb..00759619 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,6 +9,9 @@ pluginManagement { } mavenCentral() gradlePluginPortal() + maven { + url = uri("https://androidx.dev/snapshots/builds/14137143/artifacts/repository") + } } } dependencyResolutionManagement { @@ -16,6 +19,9 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven { + url = uri("https://androidx.dev/snapshots/builds/14137143/artifacts/repository") + } } }