如何在Android Studio中升级到com.android.tools.build:gradle:7.1.3

r1zhe5dt  于 2023-10-19  发布在  Android
关注(0)|答案(2)|浏览(208)

我已经将Android Studio升级到这里显示的最新版本:-

Android Studio Bumblebee | 2021.1.1 Patch 3
Build #AI-211.7628.21.2111.8309675, built on March 16, 2022
Runtime version: 11.0.11+0-b60-7590822 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 12
Registry: external.system.auto.import.disabled=true, debugger.watches.in.variables=false
Non-Bundled Plugins: org.jetbrains.kotlin (211-1.6.20-release-275-AS7442.40), com.android.aas (3.6.0)

升级完成后,我尝试将gradle升级到7.3.1

classpath 'com.android.tools.build:gradle:7.1.3'

这似乎完成了,但是我的应用程序构建现在失败了,并显示此消息

Could not find com.android.tools.build:gradle:7.1.3.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.1.3/gradle-7.1.3.pom
  - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.3/gradle-7.1.3.pom
Required by:
    project :
Add google Maven repository and sync project
Open File

我的项目gradle类似于这个

buildscript {
    ext.kotlin_version = "1.6.20"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.41'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

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

点击链接Add google Maven repository and sync project什么也不做
如何解决此生成错误?

q7solyqu

q7solyqu1#

将您的maven url

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { 
            url 'https://jitpack.io' 
        }
    }
}

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

然后按同步项目

qij5mzcb

qij5mzcb2#

我在五月份的MacBook上遇到了同样的问题。我是卸载android工作室,并再次安装更新补丁2021.1.1补丁3.但我不更新gradle插件7.1.3.我想7.1.3在Gradle网站上找不到。
https://gradle.org/releases/

plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false

}

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

}

相关问题