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

执行flutter build apk --release时依赖缺失报错,求解决方案

无法找到me.carda:AndroidAwnCore:0.7.5-dev.3.aar依赖导致Flutter Android打包失败

执行flutter build apk --release构建Android APK时出现报错,iOS构建正常,完整报错日志如下:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':awesome_notifications:generateReleaseRFile'.
> Could not resolve all files for configuration ':awesome_notifications:releaseCompileClasspath'.
   > Failed to transform AndroidAwnCore-0.7.5-dev.3.aar (me.carda:AndroidAwnCore:0.7.5-dev.3) to match attributes {artifactType=android-symbol-with-package-name, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Could not find AndroidAwnCore-0.7.5-dev.3.aar (me.carda:AndroidAwnCore:0.7.5-dev.3).
        Searched in the following locations:
            https://jitpack.io/me/carda/AndroidAwnCore/0.7.5-dev.3/AndroidAwnCore-0.7.5-dev.3.aar

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
Running Gradle task 'assembleRelease'...                            8.7s
Gradle task assembleRelease failed with exit code 1

当前配置文件

build.gradle

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.8'
        }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

settings.gradle

include ':app'

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

解决方案

  • 添加JitPack仓库:报错显示依赖托管在JitPack,但当前项目仓库配置未包含该源。修改build.gradle中的allprojects部分,新增JitPack仓库:

    allprojects {
        repositories {
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' } // 添加该行
        }
    }
    
  • 清理缓存重试:若添加仓库后仍无法拉取依赖,执行以下步骤清除缓存:

    1. 运行flutter clean清除Flutter项目缓存
    2. 删除Android目录下的.gradle文件夹
    3. 重新执行flutter build apk --release
  • 切换插件稳定版本:当前依赖的是awesome_notifications引入的开发版依赖,稳定性不足。可在pubspec.yaml中指定该插件的稳定版本,避免自动拉取开发版依赖。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 19:40:19