A problem
When I try to incorporate a package of hilt with using ksp, I came across the several errors and was not able to build my application temporaly.
Before build.gradle.kt
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
}
Before app/build.gradle.kt
plugins {
id("com.google.devtools.ksp") version "1.8.22-1.0.11" apply false
id("com.google.dagger.hilt.android") version "2.44" apply false
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
}
android {
namespace = "com.kaitokitaya.jounal"
compileSdk = 34
defaultConfig {
applicationId = "com.kaitokitaya.jounal"
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.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.cardview)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.navigation.compose)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
// Dagger Hilt
implementation(libs.hilt.android)
// You must write the both of following dependencies, hilt and dagger.
ksp(libs.dagger.compiler)
ksp(libs.hilt.compiler)
}
I got a same error here.
Could not determine the dependencies of task ':app:kspDebugKotlin' in Android project.
Cause
This problem is caused the version incompatibility that is occured by
hilt(2.44) and ksp(1.8.22-1.0.11)
In Kotlin 1.9.0, we have to use ksp (1.9.0 -1.0.12) and hilt (2.48) if ksp's version is newest.
This error doesn't show the core of problem directly. When you come across the error related on the build.gradle and something like package management in Android, you firstly address the gap of version.
(I use the newest feature of version catalog in my project.)
So I modified the following line.
// id("com.google.devtools.ksp") version "1.8.22-1.0.11" apply false
// id("com.google.dagger.hilt.android") version "2.44" apply false
id("com.google.devtools.ksp") version "1.9.0-1.0.12" apply false
id("com.google.dagger.hilt.android") version "2.48" apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
I got succeeded it.
コメント