Anonymous
Застрял с неразрешенной ссылкой: ошибка KSP в Android Gradle
Сообщение
Anonymous » 08 май 2025, 10:16
Я начал создавать простое приложение для Android. Но я застрял с
неразрешенной ссылкой: ksp ошибка. Я управляю всеми версиями плагина в libs.versions.toml. Ниже приведены файлы Gradle и Libs. Может ли кто -нибудь помочь мне, что не так с моим кодом?
Код: Выделить всё
[versions]
agp = "8.1.0"
kotlin = "1.9.0"
core-ktx = "1.10.1"
appcompat = "1.6.1"
material = "1.9.0"
constraintlayout = "2.1.4"
coroutines = "1.7.3"
lifecycle = "2.6.1"
room = "2.5.2"
recyclerview = "1.3.1"
datastore-preferences = "1.0.0"
# Testing libraries
junit = "4.13.2"
androidx-junit = "1.1.5"
espresso-core = "3.5.1"
# SDK versions
minSdk = 24
compileSdk = 34
targetSdk = 34
ksp = "1.9.0-1.0.12" # Add KSP version
[libraries]
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" }
lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore-preferences" }
# Testing libraries
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-junit" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
< /code>
settings.gradle.kts
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("gradle/libs.versions.toml"))
}
}
}
rootProject.name = "Naturo"
include(":app")
< /code>
build.gradle.kts (project) < /p>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.androidApplication) apply false // Apply Android Application plugin
alias(libs.plugins.androidLibrary) apply false // Apply Android Library plugin
alias(libs.plugins.kotlinAndroid) apply false // Apply Kotlin Android plugin
}
< /code>
build.gradle.kts (module: app) < /p>
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("androidx.navigation.safeargs.kotlin") // Add Safe Args plugin if using Navigation
id("com.google.devtools.ksp") // Use KSP for Room annotation processing
}
android {
namespace = "com.minimalapps.naturo"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
applicationId = "com.minimalapps.naturo"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = true
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 {
viewBinding = true
}
}
dependencies {
implementation(libs.core.ktx)
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.constraintlayout)
implementation(libs.recyclerview)
implementation(libs.lifecycle.viewmodel.ktx)
implementation(libs.lifecycle.runtime.ktx)
implementation(libs.coroutines.android)
implementation(libs.room.runtime)
implementation(libs.room.ktx)
ksp(libs.room.compiler) // Use ksp instead of kapt
implementation(libs.datastore.preferences)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.espresso.core)
}
Помогите мне исправить это
Подробнее здесь:
https://stackoverflow.com/questions/790 ... oid-gradle
1746688605
Anonymous
Я начал создавать простое приложение для Android. Но я застрял с [b] неразрешенной ссылкой: ksp [/b] ошибка. Я управляю всеми версиями плагина в libs.versions.toml. Ниже приведены файлы Gradle и Libs. Может ли кто -нибудь помочь мне, что не так с моим кодом?[code][versions] agp = "8.1.0" kotlin = "1.9.0" core-ktx = "1.10.1" appcompat = "1.6.1" material = "1.9.0" constraintlayout = "2.1.4" coroutines = "1.7.3" lifecycle = "2.6.1" room = "2.5.2" recyclerview = "1.3.1" datastore-preferences = "1.0.0" # Testing libraries junit = "4.13.2" androidx-junit = "1.1.5" espresso-core = "3.5.1" # SDK versions minSdk = 24 compileSdk = 34 targetSdk = 34 ksp = "1.9.0-1.0.12" # Add KSP version [libraries] core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" } appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } material = { group = "com.google.android.material", name = "material", version.ref = "material" } constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" } lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" } lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" } room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" } room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" } room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" } recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" } datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore-preferences" } # Testing libraries junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-junit" } espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } androidLibrary = { id = "com.android.library", version.ref = "agp" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } < /code> settings.gradle.kts pluginManagement { repositories { google() mavenCentral() gradlePluginPortal() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() } versionCatalogs { create("libs") { from(files("gradle/libs.versions.toml")) } } } rootProject.name = "Naturo" include(":app") < /code> build.gradle.kts (project) < /p> // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.androidApplication) apply false // Apply Android Application plugin alias(libs.plugins.androidLibrary) apply false // Apply Android Library plugin alias(libs.plugins.kotlinAndroid) apply false // Apply Kotlin Android plugin } < /code> build.gradle.kts (module: app) < /p> plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("androidx.navigation.safeargs.kotlin") // Add Safe Args plugin if using Navigation id("com.google.devtools.ksp") // Use KSP for Room annotation processing } android { namespace = "com.minimalapps.naturo" compileSdk = libs.versions.compileSdk.get().toInt() defaultConfig { applicationId = "com.minimalapps.naturo" minSdk = libs.versions.minSdk.get().toInt() targetSdk = libs.versions.targetSdk.get().toInt() versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { isMinifyEnabled = true 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 { viewBinding = true } } dependencies { implementation(libs.core.ktx) implementation(libs.appcompat) implementation(libs.material) implementation(libs.constraintlayout) implementation(libs.recyclerview) implementation(libs.lifecycle.viewmodel.ktx) implementation(libs.lifecycle.runtime.ktx) implementation(libs.coroutines.android) implementation(libs.room.runtime) implementation(libs.room.ktx) ksp(libs.room.compiler) // Use ksp instead of kapt implementation(libs.datastore.preferences) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.espresso.core) } [/code] Помогите мне исправить это Подробнее здесь: [url]https://stackoverflow.com/questions/79045761/stuck-with-unresolved-reference-ksp-error-in-android-gradle[/url]