找不到 com.android.tools.build:aapt2:8.3.1-10880808

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

升级到最新版本的 android studio (2024.2.1) 并升级 gradle 和 AGP 后,当尝试在设备上运行但 gradle 同步成功时,我遇到这些错误消息:

Could not isolate parameters com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@68af1da1 of artifact transform AarResourcesCompilerTransform
   > Could not isolate value com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@68af1da1 of type AarResourcesCompilerTransform.Parameters
      > Could not resolve all files for configuration ':app:detachedConfiguration3'.
         > Could not find com.android.tools.build:aapt2:8.3.1-10880808.
           Searched in the following locations:
             - https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/8.3.1-10880808/aapt2-8.3.1-10880808.pom
             - https://repo.maven.apache.org/maven2/com/android/tools/build/aapt2/8.3.1-10880808/aapt2-8.3.1-10880808.pom
           Required by:
               project :app

我的构建设置如下(所有文件与每个部分顶部的名称合并):

file: libs.versions.toml
[versions]
agp = "8.7.0"
junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
appcompat = "1.6.1"
material = "1.10.0"
constraintlayout = "2.1.4"
navigationFragment = "2.6.0"
navigationUi = "2.6.0"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment", version.ref = "navigationFragment" }
navigation-ui = { group = "androidx.navigation", name = "navigation-ui", version.ref = "navigationUi" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }




file: build.gradle(application)
plugins {
alias(libs.plugins.android.application) apply false
}



file: build.gradle(module :app)
plugins {
    alias(libs.plugins.android.application)
}

android {
    namespace 'com.example.myapplication'
    compileSdk 35

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 24
        targetSdk 35
        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_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation libs.appcompat
    implementation libs.material
    implementation libs.constraintlayout
    implementation libs.navigation.fragment
    implementation libs.navigation.ui
    testImplementation libs.junit
    androidTestImplementation libs.ext.junit
    androidTestImplementation libs.espresso.core
}




file: gradle-wrappers.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists


file: settings.gradle
pluginManagement {
    repositories {
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "My Application"
include ':app'



这是 android studio 的示例项目。 在 ubuntu 20.04 上运行的 android studio 2024.2.1

到目前为止我做了什么?

  • 删除android studio和所有SDK和gradle文件,并从零开始安装
  • 将 gradle JDK 版本更改为 11、17、21
  • 使用 AGP 和来自此源的 gradle 版本测试所有编译 sdk 版本 (developer.android.com
  • 删除缓存和文件并重新下载全部
  • 多次重启系统
  • 多次使缓存失效并重新启动android studio
  • 设置多个新代理(已测试代理)
  • 甚至手动下载了错误消息中存在的给定 URL
  • 从 android studio 向导多次创建新项目
  • 下载 SDK 管理器中的所有文件(~20GB)
  • 探索 stackoverflow 并完成所有接受的答案(尽管它们适用于以前的版本)

但错误尚未消失,问题仍然存在。

我相信了解 gradle 问题是一个漫长的旅程,但我失败了。

(配置和错误消息不匹配,因为我测试了所有变体并复制了错误的配置)

android android-studio android-gradle-plugin
1个回答
0
投票

老实说,当我检查URL“https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/8.3.1-10880808/aapt2-8.3.1-10880808.pom ”,它给出了正确的响应并下载 POM 文件,但是您也可以尝试下面的设置,使用自定义 Google Maven 存储库定义新的 Maven 存储库吗?

repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
    google()
}

通常 google() 是 https://dl.google.com/dl/android/maven2/ 的快捷方式,但也可能值得尝试上述设置。

链接

所有这些网址似乎都是正确的。

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