You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

多模块Jetpack Compose中Clean Project时Gradle-Lint版本兼容问题

Gradle升级后Clean Project报错(关联Android Lint配置)

在多模块Jetpack Compose项目中升级Gradle版本后,项目可正常构建并在真机运行,但执行「Clean Project」操作时触发错误。经多次测试确认,问题与Android Lint配置相关——移除Lint插件后报错消失。已尝试过清除缓存、删除.gradle目录、将主项目gradle-wrapper.properties指定为Gradle 8.10.2版本等操作,均未解决问题。

完整报错信息

* 出错原因:
应用插件请求[id: 'com.android.lint', version: '8.8.0']时发生异常
> 应用插件'com.android.internal.version-check'失败。
> 最低支持Gradle版本为8.10.2,当前版本为8.9。
如果使用Gradle wrapper,请尝试修改以下路径中的distributionUrl:
C:\Users\Lenovo\AndroidStudioProjects\SpotifyClone\build-logic\gradle\wrapper\gradle-wrapper.properties
改为gradle-8.10.2-all.zip

相关配置与代码

AndroidLintConventionPlugin代码

class AndroidLintConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
    with(target) {
        when {
            pluginManager.hasPlugin("com.android.application") ->
                configure<ApplicationExtension> { lint(Lint::configure) }

            pluginManager.hasPlugin("com.android.library") ->
                configure<LibraryExtension> { lint(Lint::configure) }

            else -> {
                apply(plugin = "com.android.lint")
                configure<Lint>(Lint::configure)
            }
        }
    }
}
}

private fun Lint.configure() {
  xmlReport = true
  sarifReport = true
  checkDependencies = true
  disable += "GradleDependency"
}

主项目gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

build-logic模块的build.gradle.kts

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
  `kotlin-dsl`
   alias(libs.plugins.android.lint)
}

group = "com.example.spotifyclone.buildlogic"

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

kotlin{
   compilerOptions {
       jvmTarget = JvmTarget.JVM_17
    }
}

dependencies {
    compileOnly(libs.android.gradlePlugin)
    compileOnly(libs.android.tools.common)
    compileOnly(libs.compose.gradlePlugin)
    compileOnly(libs.kotlin.gradlePlugin)
    compileOnly(libs.ksp.gradlePlugin)
    lintChecks(libs.androidx.lint.gradle)
}

tasks {
    validatePlugins {
        enableStricterValidation = true
        failOnWarning = true
    }
}


gradlePlugin {
   plugins {
      register("androidApplicationCompose") {
          id = "spotify.android.application.compose"
          implementationClass = "AndroidApplicationComposeConventionPlugin"
      }
    register("androidApplication") {
        id = "spotify.android.application"
        implementationClass = "AndroidApplicationConventionPlugin"
    }
    register("androidLibraryCompose") {
        id = "spotify.android.library.compose"
        implementationClass = "AndroidLibraryComposeConventionPlugin"
    }
    register("androidLibrary") {
        id = "spotify.android.library"
        implementationClass = "AndroidLibraryConventionPlugin"
    }
    register("androidFeature") {
        id = "spotify.android.feature"
        implementationClass = "AndroidFeatureConventionPlugin"
    }
    register("androidHilt") {
        id = "spotify.android.hilt"
        implementationClass = "AndroidHiltConventionPlugin"
    }
    register("androidLint") {
        id = "spotify.android.lint"
        implementationClass = "AndroidLintConventionPlugin"
    }
}
}

build-logic模块的settings.gradle.kts

pluginManagement {
   repositories {
    gradlePluginPortal()
    google()
   }
}
dependencyResolutionManagement {
   repositories {
      google()
      mavenCentral()
   }
   versionCatalogs {
       create("libs") {
          from(files("../gradle/libs.versions.toml"))
       }
   }
}

rootProject.name = "build-logic"
include(":convention")

内容的提问来源于stack exchange,提问作者Fatima Jamal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 16:54:54