diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 63a67e1..aa1e6a5 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -2,6 +2,12 @@ plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("androidx.navigation.safeargs.kotlin")
+ id("kotlin-kapt")
+ id("com.google.dagger.hilt.android")
+}
+
+kapt {
+ correctErrorTypes = true
}
android {
@@ -11,6 +17,12 @@ android {
lint {
abortOnError = false
}
+
+ packaging {
+ resources {
+ excludes += "/META-INF/{AL2.0,LGPL2.1}"
+ }
+ }
defaultConfig {
applicationId = "com.mattintech.lchat"
@@ -50,6 +62,7 @@ android {
}
buildFeatures {
viewBinding = true
+ buildConfig = true
}
}
@@ -66,6 +79,10 @@ dependencies {
implementation("androidx.navigation:navigation-fragment-ktx:2.7.6")
implementation("androidx.navigation:navigation-ui-ktx:2.7.6")
+ // Hilt dependencies
+ implementation("com.google.dagger:hilt-android:2.50")
+ kapt("com.google.dagger:hilt-compiler:2.50")
+
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index e64ca74..fe470fa 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -11,4 +11,17 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
+#-renamesourcefileattribute SourceFile
+
+# Keep Application class
+-keep class com.mattintech.lchat.LChatApplication { *; }
+
+# Hilt rules
+-keep class dagger.hilt.** { *; }
+-keep class javax.inject.** { *; }
+-keep class * extends dagger.hilt.android.internal.managers.ViewComponentManager { *; }
+
+# Keep all @HiltAndroidApp, @AndroidEntryPoint, @HiltViewModel annotated classes
+-keep @dagger.hilt.android.HiltAndroidApp class * { *; }
+-keep @dagger.hilt.android.AndroidEntryPoint class * { *; }
+-keep @dagger.hilt.android.lifecycle.HiltViewModel class * { *; }
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b8a5d57..f580b27 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -15,6 +15,7 @@
create(modelClass: Class): T {
- return when {
- modelClass.isAssignableFrom(LobbyViewModel::class.java) -> {
- LobbyViewModel(chatRepository) as T
- }
- modelClass.isAssignableFrom(ChatViewModel::class.java) -> {
- ChatViewModel(chatRepository) as T
- }
- else -> throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}")
- }
- }
-}
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index a6f97bd..fe0a227 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -11,5 +11,6 @@ buildscript {
plugins {
id("com.android.application") version "8.9.1" apply false
- id("org.jetbrains.kotlin.android") version "1.9.0" apply false
+ id("org.jetbrains.kotlin.android") version "1.9.22" apply false
+ id("com.google.dagger.hilt.android") version "2.50" apply false
}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index a6dfb2e..06a65ae 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,12 @@
# Project-wide Gradle settings.
-org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 --add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
android.useAndroidX=true
android.nonTransitiveRClass=true
-android.defaults.buildfeatures.buildconfig=true
-android.nonFinalResIds=false
\ No newline at end of file
+android.nonFinalResIds=false
+
+# Kapt configuration for better performance
+kapt.use.worker.api=true
+kapt.incremental.apt=true
+
+# Hilt configuration
+dagger.hilt.android.internal.disableAndroidSuperclassValidation=true
\ No newline at end of file