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

升级targetSDKVersion/compileSdkVersion至32后KaptDebugKotlin构建失败求助

升级compileSdkVersion/targetSdkVersion到32后app:KaptDebugKotlin任务失败(无法加载Maven元数据)

问题描述

将项目的compileSdkVersion和targetSdkVersion从30升级至32后,运行应用时app:KaptDebugKotlin任务执行失败,错误核心信息为:

Caused by: org.gradle.api.resources.ResourceException: Unable to load Maven meta-data from...

相关配置文件

模块级build.gradle

android {
compileSdkVersion 32
buildToolsVersion '29.0.3'
defaultConfig {
    applicationId "com.eschbachit.petrolinemobile"
    minSdkVersion 22
    targetSdkVersion 32
    versionCode 1628
    versionName "2.3.0"
    testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    vectorDrawables.useSupportLibrary = true
    multiDexEnabled true
}
buildTypes {
    debug {
        minifyEnabled false
        debuggable true
    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
buildFeatures {
    dataBinding true
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    mavenCentral()
}

项目级build.gradle

buildscript {
ext.kotlin_version = '1.4.20-M1'
repositories {
    jcenter()
    google()
    maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
ext {
    compiler_version = '3.1.3'
}
dependencies {
    classpath 'com.android.tools.build:gradle:4.0.2'
    classpath 'com.google.gms:google-services:4.3.4'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "com.android.tools.build:gradle:$compiler_version"
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'

}

Gradle分发版本

distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-bin.zip

解决方案

经过多轮尝试无效后,通过以下步骤解决问题:

  • 移除失效仓库:删除jcenter()和https://dl.bintray.com/kotlin/kotlin-eap仓库配置,这两个服务已停止维护,无法正常获取Maven元数据。
  • 升级Gradle生态版本:
    1. 将Gradle分发版本升级到7.0及以上(与compileSdk 32兼容)
    2. 更新Android Gradle Plugin到7.0.0及以上版本
    3. 将Kotlin版本替换为1.5.31及以上的稳定版本
  • 调整仓库依赖:保留google()和mavenCentral()作为核心仓库,确保所有依赖能从有效地址拉取。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 02:45:34