Android Kotlin KSP плагин с каталогами GradleAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Android Kotlin KSP плагин с каталогами Gradle

Сообщение Anonymous »

Я пытаюсь использовать комнату в своем проекте Android, который я использую с помощью функции каталогов Gradle Version. Сделайте их работать вместе.libs.versions.toml
[versions]
agp = "8.1.2"
// ...
androidx-room = "2.3.0-beta02"
com-google-devtools-ksp = "1.8.10-1.0.9"

[libraries]

# Implementations
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
// ...
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "androidx.room" }
androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "androidx.room" }
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "androidx.room" }

[plugins]
com-android-application = { id = "com.android.application", version.ref = "agp" }
// ...
com-google-devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "com-google-devtools-ksp" }

[bundles]
< /code>

build.gradle.kts (:app)
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.com.android.application)
// ..
alias(libs.plugins.com.google.devtools.ksp)
}

android {
// ...
defaultConfig {
// ...
minSdk = 24
// noinspection EditedTargetSdkVersion
targetSdk = 34
versionCode = 1
versionName = "1.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

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 {
viewBinding = true
}
}

dependencies {
implementation(libs.core.ktx)
// ...
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.room.runtime)
ksp(libs.androidx.room.compiler)

// Test
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.espresso.core)

// Test Android

testImplementation(libs.junit)
testImplementation(libs.io.insert.koin.test)
}
< /code>

build.gradle.kts (Top-level build file)
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.com.android.application) apply false
/// ...
alias(libs.plugins.org.jetbrains.kotlin.plugin.parcelize) apply false
}
true // Needed to make the Suppress annotation work for the plugins block
< /code>

The error I'm getting is this one:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> class org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData (org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6404c62a; org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @3df7681e)

(...)

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.

(...)

org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
Caused by: java.lang.ClassCastException: class org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData (org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6404c62a; org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @3df7681e)

(...)
< /code>

и это:
class org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData (org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6404c62a; org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @3df7681e)
class org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData (org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation_Decorated is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6404c62a; org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @3df7681e)

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.


Подробнее здесь: https://stackoverflow.com/questions/773 ... e-catalogs
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»