无法在上一个 gradle 版本的 android studio 中解析 jitpack 依赖项

Cannot resolve jitpack dependencies in android studio in the last gradle version

我收到 Failed to resolve: com.github.dogecoin:libdohj:v0.15.9 错误,我不知道为什么。我还尝试了其他 jitpack 依赖项。它在我以前的项目中运行良好。

buildscript {
    ext {
        compose_version = '1.0.2'
    }
    repositories {
        google()
        maven { url "https://jitpack.io" }
        mavenCentral()

    }

    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

我将 maven { url "https://jitpack.io" } 添加到 settings.gradle 并解决了问题。

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url "https://jitpack.io" }

    }
}
rootProject.name = "Crypto World"
include ':app'

在Gradle的新版本(7.2)中有些地方发生了变化,所以你需要这样做:

1-检查您的 gradle 版本

2- 打开 build.gradle(project:---)

3- 如果喜欢下面的代码,转到下一步

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

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

4- 打开 stting.gradle(---)

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }

5- 立即同步并完成