android - 找不到 aapt2-proto-7.0.0-beta04-7396180.jar

标签 android flutter android-studio gradle build.gradle

我正在做 Flutter 项目,突然出现这个问题:

Launching lib\main.dart on RMX3031 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_plugin_android_lifecycle:extractDebugAnnotations'.
> Could not resolve all files for configuration ':flutter_plugin_android_lifecycle:detachedConfiguration2'.
   > Could not find aapt2-proto-7.0.0-beta04-7396180.jar (com.android.tools.build:aapt2-proto:7.0.0-beta04-7396180).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-proto/7.0.0-beta04-7396180/aapt2-proto-7.0.0-beta04-7396180.jar

* 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 11s
Exception: Gradle task assembleDebug failed with exit code 1

我搜索了很多,但没有关于这个错误的任何问题。

android/build.gradle:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
        maven {
            url 'http://download.flutter.io'
            allowInsecureProtocol = true
        }
    }

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

}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'http://download.flutter.io'
            allowInsecureProtocol = true
        }
    }

}

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

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

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
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility "1.8"
        targetCompatibility "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.example.supernew"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

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

我可以手动下载 aapt2-proto-7.0.0-beta04-7396180.jar 但是我如何将它添加到我的 flutter 项目或 gradle 中...

谁能帮我解决这个问题,非常感谢。

最佳答案

删除以下目录的所有内容。

1- C:\Users\USER_NAME.android\build-cache

2- C:\Users\USER_NAME.android\cache

3- C:\Users\USER_NAME.gradle\caches (如果不起作用则可选)

关于android - 找不到 aapt2-proto-7.0.0-beta04-7396180.jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72795797/

相关文章:

android - SYSTEM_UI_FLAG_LAYOUT_STABLE 和 SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 有什么作用

Flutter SharedPreferences 值在应用程序启动时提供给 Provider

android - 使用 gradle 构建时出现 java.lang.ClassCastException : com. sun.tools.javac.code.Symbol$VarSymbol

java - 使用 Retrofit 发送 FormUrlEncoded 时出现问题

Android如何集成一个AsyncTask

android - TextView 未更新?

flutter - 文字溢出,无法控制

flutter - Flutter-类型 'BoxDecoration'不是类型 'Widget'的子类型

android - 我应该如何在 android studio 中设置 gradle 4.5 的类路径

android - 想在应用程序中添加设计库