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

运行Android应用时触发CheckAarMetadataWorkAction执行失败,求解决

Android构建错误:CheckAarMetadataWorkAction执行失败

运行Android应用时触发以下错误:

Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction

项目配置文件如下:

build.gradle(Module:app)

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

android {
    namespace 'com.example.adore'
    compileSdk 32

    defaultConfig {
        applicationId "com.example.adore"
        minSdk 24
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation platform('com.google.firebase:firebase-bom:32.2.2')
    implementation 'com.google.firebase:firebase-analytics'

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.annotation:annotation:1.6.0'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
    implementation 'com.google.firebase:firebase-auth:22.1.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

build.gradle(project)

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.15'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '8.1.0' apply false
    id 'com.android.library' version '8.1.0' apply false
    id 'com.google.gms.google-services' version '4.3.15' apply false
}

解决步骤

  • 升级compileSdk和targetSdk版本:当前项目使用的compileSdk 32与Firebase BOM 32.2.2不兼容,Firebase该版本要求compileSdk至少为33。修改Module的build.gradle:

    android {
        compileSdk 33
    
        defaultConfig {
            targetSdk 33
        }
    }
    
  • 移除重复的Firebase依赖:已经通过Firebase BOM管理版本,无需单独声明firebase-auth,删除dependencies中的这一行:

    implementation 'com.google.firebase:firebase-auth:22.1.1'
    
  • 更新Google Services插件版本:将项目级build.gradle中的插件版本升级到4.4.0,提升兼容性:

    plugins {
        id 'com.google.gms.google-services' version '4.4.0' apply false
    }
    buildscript {
        dependencies {
            classpath 'com.google.gms:google-services:4.4.0'
        }
    }
    
  • 清理并重建项目:执行Sync Project with Gradle Files,然后依次运行Clean Project和Rebuild Project,清除旧缓存。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 21:35:31