Die Methode „java.lang.String com.squareup.javapoet.ClassName.canonicalName()“ konnte nicht gefunden werden.Android

Forum für diejenigen, die für Android programmieren
Anonymous
 Die Methode „java.lang.String com.squareup.javapoet.ClassName.canonicalName()“ konnte nicht gefunden werden.

Post by Anonymous »

Das Gradle-Skript wird korrekt synchronisiert, aber wenn ich versuche, die Anwendung auszuführen, erhalte ich die folgende Fehlermeldung:

Code: Select all

Unable to find method ''java.lang.String com.squareup.javapoet.ClassName.canonicalName()''
'java.lang.String com.squareup.javapoet.ClassName.canonicalName()'

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.
Ich habe bereits alle Vorschläge von Android Studio ausprobiert und das Problem nicht gelöst. Ich habe auch hier auf Stack Overflow einen ähnlichen Fall überprüft und kann keine Lösung finden.
In dem Projekt verwende ich Hilt für die Abhängigkeitsinjektion und ich habe das Gefühl, dass das Problem vorhanden sein könnte, aber egal wie viel ich überprüfe, alle Anmerkungen sind korrekt.
Dies ist das Gradle-Skript auf Modulebene

Code: Select all

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.ksp)
alias(libs.plugins.hilt.plugin)
}

android {
namespace = "com.bdavidgm.consumoelectrico"
compileSdk = 36

defaultConfig {
applicationId = "com.bdavidgm.consumoelectrico"
minSdk = 26
targetSdk = 36
versionCode = 1
versionName = "1.0"

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

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
}
}

configurations.all {
resolutionStrategy {
eachDependency {
if (requested.group == "com.squareup" && requested.name == "javapoet") {
useVersion("1.13.0")
}
}
}
}

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.room.common.jvm)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.runtime)
implementation(libs.material3)
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)

// For datastore
// Preferences DataStore (SharedPreferences like APIs)
implementation("androidx.datastore:datastore-preferences:1.2.0")

// Alternatively - without an Android dependency.
implementation("androidx.datastore:datastore-preferences-core:1.2.0")

// For encryption
implementation("androidx.security:security-crypto:1.1.0")

// Hilt
implementation("com.google.dagger:hilt-android:2.57.1")
ksp("com.google.dagger:hilt-android-compiler:2.57.1")

//material icons
implementation("androidx.compose.material:material-icons-core:1.7.8")
implementation("androidx.compose.material:material-icons-extended:1.7.8")
}
Gradle-Skript auf Projektebene

Code: Select all

plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
}
Dies ist die Datei libs.versions.toml:

Code: Select all

[versions]
agp = "8.12.3"
kotlin = "2.0.21"
coreKtx = "1.10.1"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
lifecycleRuntimeKtx = "2.9.4"
activityCompose = "1.11.0"
composeBom = "2024.09.00"
roomCommonJvm = "2.8.4"
roomKtx = "2.8.4"
runtime = "1.9.5"
material3 = "1.4.0"
comGoogleDevtoolsKspGradlePlugin = "1.5.30-1.0.0"
kspver = "2.0.21-1.0.27"  # Use an updated and compatible KSP version for Kotlin 2.0.21
hiltver = "2.57.2"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-room-common-jvm = { group = "androidx.room", name = "room-common-jvm", version.ref = "roomCommonJvm" }
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "roomKtx" }
androidx-runtime = { group = "androidx.compose.runtime", name = "runtime", version.ref = "runtime" }
material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "material3" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "kspver" }
hilt-plugin = { id = "com.google.dagger.hilt.android", version.ref = "hiltver" }
Und das komplette Projekt finden Sie unter:
https://github.com/bdavidgm/Consumo-electrico.git

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post