Как избавиться от этой ошибки сборки «Невозможно загрузить класс 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.58"
androidx_appcompat = "1.7.1"
constraintlayout = "2.2.1"
hiltCompiler = "2.58"
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 = "8.13.0"
androidx_activity = "1.12.2"
google_services_gms = "4.4.4"
dagger_hilt_android = "2.58"
kotlin_compose = "2.3.0"
androidx_savedstate = "1.4.0"
compose_version = "1.10.1"
ksp_version = "2.3.0"
android_kotlin = "2.3.0"

[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", version.ref = "dagger_hilt_android"}
kotlin_compose = {id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin_compose"}
kotlin = {id = "org.jetbrains.kotlin.android", version.ref = "android_kotlin"}
ksp_devtools = {id = "com.google.devtools.ksp", version.ref = "ksp_version"}

App Build.gradle
// Файл сборки верхнего уровня, куда вы можете добавить параметры конфигурации, общие для всех подпроектов/модулей.
plugins {
alias(libs.plugins.android.gradle) apply false
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
alias(libs.plugins.kotlin) apply false
}

App Build.gradle
import com.android.build.api.dsl.ApplicationExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import java.util.Properties
import java.io.FileInputStream

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

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

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.kotlin)
alias(libs.plugins.ksp.devtools)

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

kotlin{
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
}

}

extensions.configure {
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"

val mapsApiKey = secrets.getProperty("GOOGLE_MAPS_API_KEY") ?: ""
buildConfigField("String", "GOOGLE_MAPS_API_KEY", "\"$mapsApiKey\"")
manifestPlaceholders["GOOGLE_MAPS_API_KEY"] = mapsApiKey

val firebaseApiKey = secrets.getProperty("FIREBASE_API_KEY") ?: ""
buildConfigField("String", "FIREBASE_API_KEY", "\"$firebaseApiKey\"")
manifestPlaceholders["FIREBASE_API_KEY"] = firebaseApiKey

val stripeApiKey = secrets.getProperty("STRIPE_API_KEY") ?: ""
buildConfigField("String", "STRIPE_API_KEY", "\"$stripeApiKey\"")
manifestPlaceholders["STRIPE_API_KEY"] = stripeApiKey

val bestBuyApiKey = secrets.getProperty("BEST_BUY_API_KEY") ?: ""
buildConfigField("String", "BEST_BUY_API_KEY", "\"$bestBuyApiKey\"")
manifestPlaceholders["BEST_BUY_API_KEY"] = bestBuyApiKey
}

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

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
}

}

hilt {
enableAggregatingTask = true
}

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)

}

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

Root Build.gradle

// Файл сборки верхнего уровня, в который можно добавить параметры конфигурации, общие для всех подпроектов/модулей.
plugins {
alias(libs.plugins.android.gradle) apply false
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
alias(libs.plugins.kotlin) apply false
}

Gradle Wrapper properties

#Чт, 22 января, 21:59:02 по тихоокеанскому стандартному времени 2026 г.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists



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

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

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

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

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

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