When I use the latest version of Android Studio, I am facing with this problem. On my other project exactly same dependencies are implemented, but there is no problem. Here I am facing these kinds of errors
Type mismatch: inferred type is String but KaptOptions was expected Type mismatch: inferred type is () -> Unit but KaptOptions was expected Unresolved reference: correctErrorTypes
Here is my build.gradle(Module) file:
import org.jetbrains.kotlin.kapt3.base.Kapt.kapt
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id ("kotlin-kapt")
id ("com.google.dagger.hilt.android")
}
android {
namespace = "com.urahimli.booklistbeta"
compileSdk = 34
defaultConfig {
applicationId = "com.urahimli.booklistbeta"
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.3.2"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.activity:activity-compose:1.7.2")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
// Compose dependencies
implementation ("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
implementation ("androidx.navigation:navigation-compose:2.7.0")
implementation ("androidx.hilt:hilt-navigation-compose:1.1.0-alpha01")
// Coroutines
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2")
//Dagger - Hilt
implementation ("com.google.dagger:hilt-android:2.46.1")
kapt ("com.google.dagger:hilt-android-compiler:2.46.1")
kapt ("androidx.hilt:hilt-compiler:1.0.0")
// Room
implementation ("androidx.room:room-runtime:2.5.2")
kapt ("androidx.room:room-compiler:2.5.2")
// Kotlin Extensions and Coroutines support for Room
implementation ("androidx.room:room-ktx:2.5.2")
//material 3
implementation("androidx.compose.material3:material3:1.1.1")
implementation("androidx.compose.material:material-icons-extended:1.5.0")
}
kapt {
correctErrorTypes = true
}
and here is my build.gradle(Project) file:
plugins {
id("com.android.application") version "8.1.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
id("com.google.devtools.ksp") version "1.8.10-1.0.9" apply false
}
as I said, I think all these things happen after creating a new project. On my old project, there is no problem. I need your solutions
You're missing
id("com.google.dagger.hilt.android") version "2.47" apply false
In your project-level build.gradle.kts
file.
I tested adding it in and that seems to fix it.