运行 flutter build apk --release 时出现错误

问题描述 投票:0回答:1

当我运行这个命令时

flutter build apk --release
我有这样的错误

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
}

我的setting.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"

我在ios上调试它没问题,但是当在android上调试时出现像上面这样的错误,我分享

我想将我的 flutter 应用程序构建为 apk 且没有错误,我该怎么办?

android flutter gradle mobile build.gradle
1个回答
0
投票

您可以尝试更改 pubspec.yaml 中的 awesome_notifications

版本

尝试:

删除构建文件夹:rm -rf build/ 删除android目录下的.gradle文件夹 运行 flutter pub 缓存修复

© www.soinside.com 2019 - 2024. All rights reserved.