android Flutter:执行任务“:app:checkProgAarMetadata”失败,无法解析配置“:app:debugRuntimeClasspath”的所有文件

rkue9o1l  于 2023-11-15  发布在  Android
关注(0)|答案(2)|浏览(157)

我有一个运行良好的应用程序,但在更新到最新版本的flutter 2.8.1后,它开始显示有关gradle文件的错误。
错误是:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find core-1.6.0.aar (androidx.core:core:1.6.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/core/core/1.6.0/core-1.6.0.aar
   > Could not find core-1.6.0.aar (androidx.core:core:1.6.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/core/core/1.6.0/core-1.6.0.aar
   > Could not find tracing-1.0.0.aar (androidx.tracing:tracing:1.0.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/tracing/tracing/1.0.0/tracing-1.0.0.aar
   > Could not find versionedparcelable-1.1.1.aar (androidx.versionedparcelable:versionedparcelable:1.1.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/versionedparcelable/versionedparcelable/1.1.1/versionedparcelable-1.1.1.aar
   > Could not find versionedparcelable-1.1.1.aar (androidx.versionedparcelable:versionedparcelable:1.1.1).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/versionedparcelable/versionedparcelable/1.1.1/versionedparcelable-1.1.1.aar
   > Could not find annotation-experimental-1.1.0.aar (androidx.annotation:annotation-experimental:1.1.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.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 58s
Exception: Gradle task assembleDebug failed with exit code 1

字符串
正如你可以看到android studio无法在网上找到一些文件,但实际上当我按照错误中提供的链接,我可以下载这些文件,但作为.zip.aar
现在,通常当我遇到这样的错误时,我只需手动下载文件并将其放置在各自的文件夹中,我们可以从错误本身获得,例如:
如果我们看一下第一个文件是core-1.6.0.aar,我们可以看到它的文件夹是androidx.core\core\1.6.0,并且在该文件夹中Android Studio生成另一个文件夹,其随机名称为7664385a7e39112b780baf8819ee880dcd3c4094,因此完整路径如下所示:

C:\Users\%USERNAME%\.gradle\caches\modules-2\files-2.1\androidx.core\core\1.6.0\<here goes the folder with the random name>


但是对于上面提到的文件,android studio没有生成任何文件夹,所以我不知道该怎么处理它们,我应该把它们放在哪里?或者有什么方法来解决错误并摆脱它?
我的android\app\build.gradle文件:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion flutter.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.bkh.pharmart"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}


我的android\build.gradle文件:

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

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

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

task clean(type: Delete) {
    delete rootProject.buildDir
}


先谢了。

gupuwyp2

gupuwyp21#

我昨天遇到了这个问题。3个小时后。我找到了一个方法。关闭Android Studio,
删除C:\Users\<USER>\.gradle文件夹(或删除它)
用一个好的VPN重新构建项目
我更喜欢使用Cisco Any connect协议的VPN。
这是我的build.gradle和我加的一些repository也许可以帮到你.

buildscript {
    repositories {
//        google()
//        mavenCentral()
        mavenCentral()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

allprojects {
    repositories {
//        google()
//        mavenCentral()
        mavenCentral()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

字符串

lokaqttq

lokaqttq2#

将latest更新为Gradle的最新版本,然后运行

flutter clean 
flutter run

字符串

相关问题