Как избавиться от этой ошибки сборки «Невозможно загрузить класс com.android.build.gradle.api.BaseVariant»Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Как избавиться от этой ошибки сборки «Невозможно загрузить класс com.android.build.gradle.api.BaseVariant»

Сообщение Anonymous »

В моем проекте Android Studio у меня нет предела проблемам с корректной работой всех моих плагинов с Gradle 9.2.1-bin. Я продолжаю получать эту ошибку: «Невозможно загрузить класс 'com.android.build.gradle.api.BaseVariant'
com.android.build.gradle.api.BaseVariant», несмотря на все предложения Gemini.
Вот список всех моих настроек в моем файле TOML:
AGP: 9.1.0-alpha05
KSP: 2.3.4 (with ksp.useKSP2=true in gradle properties)
Kotlin: I've removed because from my understanding is that using Gradle 9.0+, Kotlin support is built in
Hilt: 2.59
Gradle Secrets: I removed and stored my keys in local.properties because I understand that from AGP 8.0+ it has been deprecated.

Я удалил папки .gradle и build, выполнил сброс недействительных кешей, но проблемы все еще возникают. Я попытался понизить версию Gradle до 8.13.2, но все равно получил ужасную ошибку «Невозможно загрузить...». Где мне посмотреть, какие версии плагинов совместимы с выбранным мной AGP?
libs.versions.toml

[versions]

activityCompose = "1.12.2"
androidx_core_ktx = "1.17.0"
hilt_android_gradle_version = "2.59"
androidx_appcompat = "1.7.1"
constraintlayout = "2.2.1"
hiltCompiler = "2.59"
javax_annotation = "1.3.2"
androidx_privacysandbox_tools = "1.0.0-alpha14"
firebase_storage_ktx = "21.0.2"
play_services_identity = "18.1.0"
junit = "4.13.2"
androidx_test_ext_junit = "1.3.0"
androidx_fragment_ktx = "1.8.9"
androidx_hilt_compiler = "1.3.0"
androidx_activity_ktx = "1.12.2"
androidx_lifecycle = "2.10.0"
glide_compose = "1.0.0-beta08"
retrofit = "3.0.0"
okhttp3 = "5.3.2"
kotlinx_coroutines = "1.10.2"
firebase_bom = "34.8.0"
play_services_places = "5.1.1"
maps_compose = "7.0.0"
stripe_android = "22.6.0"
stripe_java = "31.2.0"
volley = "1.2.1"
androidx_multidex = "2.0.1"
androidx_compose_material3 = "1.4.0"
android_gradle_plugin_version = "9.1.0-alpha05"
androidx_activity = "1.12.2"
google_services_gms = "4.4.4"
dagger_hilt_android = "2.59"
kotlin_compose = "2.3.0"
androidx_savedstate = "1.4.0"
compose_version = "1.10.1"
ksp_version = "2.3.4"

[libraries]

androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "androidx_core_ktx" }
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx_lifecycle" }
androidx-material3 = { module = "androidx.compose.material3:material3" }
androidx-ui = { module = "androidx.compose.ui:ui" }
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui- test-manifest" }
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
firebase-auth = { module = "com.google.firebase:firebase-auth" }
firebase-firestore = { module = "com.google.firebase:firebase-firestore" }
hilt_compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hiltCompiler" }
hilt_android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt_android_gradle_version" }
androidx_appcompat = {group = "androidx.appcompat", name = "appcompat", version.ref = "androidx_appcompat"}
constraintlayout = {group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout"}
javax_annotation_api = {group = "javax.annotation", name = "javax.annotation-api", version.ref = "javax_annotation"}
androidx_lifecycle_viewmodel_ktx = {group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "androidx_lifecycle"}
androidx_privacysandbox_tools = {group = "androidx.privacysandbox.tools", name = "tools-core", version.ref = "androidx_privacysandbox_tools"}
firebase_storage_ktx = {group = "com.google.firebase", name = "firebase-storage-ktx", version.ref = "firebase_storage_ktx"}
play_services_identity = {group = "com.google.android.gms", name = "play-services-identity", version.ref = "play_services_identity"}
junit = {group = "junit", name = "junit", version.ref = "junit"}
androidx_test_ext_junit = {group = "androidx.test.ext", name = "junit", version.ref = "androidx_test_ext_junit"}
androidx_fragment_ktx = {group = "androidx.fragment", name = "fragment-ktx", version.ref = "androidx_fragment_ktx"}
androidx_hilt_compiler = {group = "androidx.hilt", name = "hilt-compiler", version.ref = "androidx_hilt_compiler"}
androidx_activity_ktx = {group = "androidx.activity", name = "activity-ktx", version.ref = "androidx_activity_ktx"}
androidx_lifecycle_runtime_ktx = {group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidx_lifecycle"}
androidx_lifecycle_livedata_ktx = {group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "androidx_lifecycle"}
androidx_lifecycle_runtime_compose = {group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx_lifecycle"}
androidx_lifecycle_viewmodel_savedstate = {group = "androidx.lifecycle", name = "lifecycle-viewmodel-savedstate", version.ref = "androidx_lifecycle"}
glide_compose = {group = "com.github.bumptech.glide", name = "compose", version.ref = "glide_compose"}
retrofit = {group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit"}
converter_gson = {group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit"}
okhttp3 = {group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp3"}
kotlinx_coroutines = {group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx_coroutines"}
firebase_bom = {group = "com.google.firebase", name = "firebase-bom", version.ref = "firebase_bom"}
play_services_places = {group = "com.google.android.libraries.places", name = "places", version.ref = "play_services_places"}
maps_compose = {group = "com.google.maps.android", name = "maps-compose", version.ref = "maps_compose"}
androidx_multidex = {group = "androidx.multidex", name = "multidex", version.ref = "androidx_multidex"}
androidx_compose_material3 = {group = "androidx.compose.material3", name = "material3", version.ref = "androidx_compose_material3"}
stripe_android = {group = "com.stripe", name = "stripe-android", version.ref = "stripe_android"}
stripe_java = {group = "com.stripe", name = "stripe-java", version.ref = "stripe_java"}
ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
volley = {group = "com.android.volley", name = "volley", version.ref = "volley"}
compose_ui = {group = "androidx.compose.ui", name = "ui", version.ref = "compose_version"}
compose_foundation = {group = "androidx.compose.foundation", name = "foundation", version.ref = "compose_version"}
compose_material = {group = "androidx.compose.material", name = "material", version.ref = "compose_version"}
compose_runtime = {group = "androidx.compose.runtime", name = "runtime", version.ref = "compose_version"}
compose_animation = {group = "androidx.compose.animation", name = "animation", version.ref = "compose_version"}
compose_ui_test = {group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "compose_version"}
androidx_activity = {group = "androidx.activity", name = "activity", version.ref = "androidx_activity"}
androidx_savedstate = {group = "androidx.savedstate", name = "savedstate", version.ref = "androidx_savedstate"}

[plugins]

android_gradle = {id = "com.android.application", version.ref = "android_gradle_plugin_version"}
google_gms = {id = "com.google.gms.google-services", version.ref = "google_services_gms"}
dagger_hilt_android = {id = "com.google.dagger.hilt.android", n version.ref = "dagger_hilt_android"}
kotlin_compose = {id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin_compose"}
ksp_devtools = {id = "com.google.devtools.ksp", version.ref = "ksp_version"}enter code here

App Build.gradle

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import java.util.Properties
import java.io.FileInputStream

plugins {

alias(libs.plugins.android.gradle)
alias(libs.plugins.dagger.hilt.android)
alias(libs.plugins.google.gms)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.ksp.devtools)

}

android {
namespace = "com.tritongames.shoppingwishlist"
compileSdk = 36

defaultConfig {
applicationId = "com.tritongames.shoppingwishlist"
minSdk = 26

targetSdk = 36
versionCode = 1
versionName = "1.0"

multiDexEnabled = true

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

// 1. Load the properties safely
val secretsFile = rootProject.file("local.properties")
val secrets = Properties()

if (secretsFile.exists()) {
secretsFile.inputStream().use {
secrets.load(it)
}
}

// Use the key from secrets.properties, or a fallback if missing
val mapsApiKey = secrets.getProperty("GOOGLE_MAPS_API_KEY") ?: ""

manifestPlaceholders["GOOGLE_MAPS_API_KEY"] = mapsApiKey

}

buildFeatures {
viewBinding = true
compose = true
buildConfig = true
}

configurations {
implementation {
// In Kotlin, modules are strings and must be in quotes
exclude(group = "com.google.protobuf", module = "protobuf-java")
}
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
isDebuggable = true // Warning: Keeping this 'true' means Google Play may reject it
proguardFiles(
getDefaultProguardFile("proguard-android- optimize.txt"),
"proguard-rules.pro"
)
}

getByName("debug") {
isDebuggable = true
isJniDebuggable = true
enableUnitTestCoverage = false
enableAndroidTestCoverage = false
}

// Creating a custom build type named "staging" or similar
// instead of naming it "debuggable" to avoid property conflicts
register("staging") {
initWith(getByName("debug"))
// You can override specific debug settings here
isJniDebuggable = true
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

kotlin {
compilerOptions {
jvmTarget = JvmTarget.fromTarget("21")
}
}

hilt {
enableAggregatingTask = true
}

configurations.configureEach {
exclude(group = "com.intellij", module = "annotations")
}

dependencies {

implementation(libs.androidx.activity)
implementation(libs.androidx.activity.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.savedstate)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.core)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.fragment.ktx)
implementation(libs.androidx.lifecycle.viewmodel.savedstate)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.multidex)
androidTestImplementation(libs.androidx.test.ext.junit)
implementation(libs.constraintlayout)
implementation (platform(libs.firebase.bom))
implementation(libs.firebase.storage.ktx)
implementation(libs.glide.compose)
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
testImplementation(libs.junit)
implementation(libs.kotlinx.coroutines)
implementation(libs.maps.compose)
implementation(libs.okhttp3)
implementation(libs.play.services.identity)
implementation(libs.play.services.places)
implementation(libs.retrofit)
implementation(libs.converter.gson)
implementation(libs.stripe.android)
implementation(libs.stripe.java)
implementation(libs.volley)
implementation(libs.javax.annotation.api)
implementation(libs.compose.ui)
implementation(libs.compose.foundation)
implementation(libs.compose.material)
implementation(libs.compose.runtime)
implementation(libs.compose.animation)
implementation(libs.compose.ui.test)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.material3)
implementation(libs.androidx.ui)
implementation(libs.ui.test.junit4)
implementation(libs.androidx.ui.test.junit4)
implementation(libs.androidx.ui.test.manifest)
implementation(libs.androidx.ui.tooling)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.firebase.auth)
implementation(libs.firebase.firestore)
implementation(libs.androidx.privacysandbox.tools)
implementation(libs.androidx.hilt.compiler)
implementation(libs.androidx.lifecycle.runtime.compose)

}

secrets {
// To add your Maps API key to this project:
// 1. If the secrets.properties file does not exist, create it in the same folder as the local.properties file.
// 2. Add this line, where YOUR_API_KEY is your API key:
// MAPS_API_KEY=YOUR_API_KEY
propertiesFileName = "local.properties"

// A properties file containing default secret values. This file can be
// checked in version control.
defaultPropertiesFileName = "local.defaults.properties"
}

tasks.register("checkMySecret") {
// 1. Load properties (Logic happens during configuration)
val properties = Properties()
val secretsFile = project.rootProject.file("secrets.properties")

if (secretsFile.exists()) {
secretsFile.inputStream().use { properties.load(it) }
}

val apiKey = properties.getProperty("MAPS_API_KEY")

// 2. The actual task execution logic
doLast {
println("--- SECRET CHECK ---")
if (apiKey != null) {
println("✅ Key found: $apiKey") // Using Kotlin string interpolation
} else {
println("❌ Key NOT found. Check your secrets.properties file.")
}
println("--------------------")
}
}
}

Root Build.gradle

plugins {
alias(libs.plugins.google.gms) apply false
alias(libs.plugins.dagger.hilt.android) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.ksp.devtools) apply false
}

Gradle Wrapper properties

#Thu Jan 22 12:20:35 PST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Setting Gradle

pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()

}
}
rootProject.name = "ShoppingWishList"
include ':app'


Подробнее здесь: https://stackoverflow.com/questions/798 ... d-build-gr
Ответить

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

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

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

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

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