簡體   English   中英

Android 工作室 Gradle 找不到 gradle-7.4.0.jar

[英]Android Studio Gradle Could not find gradle-7.4.0.jar

我在 android 工作室 gradle 處理了幾個小時的問題,我無法解決。

我只是想構建我的第一個項目,但 gradle 有問題。這就是我的 build.gradle 文件的樣子:

plugins {
    id 'com.android.application' version '7.4.0' apply false
    id 'com.android.library' version '7.4.0' apply false
}

在此處輸入圖像描述

這是問題的上下文:

A problem occurred configuring root project 'My Application'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find gradle-7.4.0.jar (com.android.tools.build:gradle:7.4.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.4.0/gradle-7.4.0.jar
   > Could not find builder-7.4.0.jar (com.android.tools.build:builder:7.4.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/7.4.0/builder-7.4.0.jar
   > Could not find bundletool-1.11.4.jar (com.android.tools.build:bundletool:1.11.4).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.11.4/bundletool-1.11.4.jar
   > Could not find protos-30.4.0.jar (com.android.tools.analytics-library:protos:30.4.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/30.4.0/protos-30.4.0.jar

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

我還添加了圖像。

我不知道如何解決這個問題,我們將不勝感激。

我觀察到同樣的問題。 我發現了一些模棱兩可的地方,可以解釋發生了什么。

如果您導航到https://maven.google.com/web/index.html#com.android.tools.build.gradle:7.4.0 ,您將獲得一個 web 頁面,該頁面將為您提供有關 com.8824.18840 的信息gradle-7.4.0。 如果您 hover 通過 jar 或 pom 文件的鏈接,您將獲得與您的搜索指示的不同的 url: https://dl.google.com/android/maven2/com/android/tools/build.gradle /7.4.0/gradle-7.4.0.jar 請注意,缺少“/dl/”部分。 這至少是我的瀏覽器在瀏覽器底部顯示的內容 window。看到這一點,我進入了我的 setting.gradle.kts 文件並通過添加以下存儲庫來編輯我的 pluginManagment 存儲庫部分:

         maven {
            url = uri("https://dl.google.com/android/maven2/")
         }

然后我能夠構建我的項目,而不會出現有關找不到 com.android.tools.build.gradle 插件的錯誤。 就我而言,我看到了一個略有不同的搜索位置列表。 我的失敗是因為它無法處理 gradle-7.4.0.pom 文件,而不是 jar 文件。 所以,我並沒有完全看到你所看到的,但它很有可能是相關的,因為在從存儲庫解析插件工件時,通常會在 jar 文件之前讀取 pom 文件。

當我遇到問題時,我會復制搜索到的存儲庫的鏈接並將其粘貼到瀏覽器中,果然我會使用搜索到的 url 位置得到 http 404 錯誤。 當我通過刪除鏈接的“/dl/”部分修改鏈接時,文件將下載。 所以,你可能認為我的解釋解釋了這個問題。 然而,在我解決問題后,我在瀏覽器中重新輸入了失敗的 URL(帶有“/dl/”部分的 url),但這次它正常工作,沒有任何錯誤。 關於為什么 url 有時工作有時失敗,我能想到的唯一解釋是處理 url 請求的服務器或代理服務器有時離線。

綜上所述,您可能會遇到下一個問題。 為了使用 android gradle 7.4,您必須使用高於 Android Studio Dolphin 的 android Studio 版本 | 2021.3.1 Patch 1. see https://developer.android.com/studio/releases#android_gradle_plugin_and_android_studio_compatibility Unfortunately, it is my understanding that all of the versions of Android Studio, that would be compatible with using android gradle plugin 7.4 are only available作為預覽 Android Studio 版本。 因此,如果您正在開發並限制自己僅使用正式發布的穩定工具構建代碼,那么您將無法使用 android gradle 插件 7.3.1,直到下一個版本的 android studio 正式發布。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM