Android:解析失败:com.github.vpotvin:caldroidx:1.0

Android: Failed to resolve: com.github.vpotvin:caldroidx:1.0

我正在尝试将 CaldroidX 库集成到我的应用程序中 (https://github.com/vpotvin/CaldroidX)。但是,我收到以下错误:

Failed to resolve: com.github.vpotvin:caldroidx:1.0

这看起来很奇怪,因为我相信我已经正确地遵循了说明:

  1. 在项目级别 build.gradle 中指定 maven { url 'https://jitpack.io' }
  2. 在应用级别 build.gradle 中指定 implementation 'com.github.vpotvin:caldroidx:1.0'

下面是我的项目级build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}

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

下面是我的应用级别build.gradle:

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.hijriconversioncalendar"
        minSdkVersion 26
        targetSdkVersion 30
        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
    }
}

dependencies {
    implementation 'com.github.vpotvin:caldroidx:1.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

您在错误的位置添加了 maven 存储库,更改您的项目级别 gradle 文件,例如,

// Top-level build file where you can add configuration options common to all 
sub-projects/modules.
buildscript {
repositories {
    google()
    mavenCentral()
   
}
dependencies {
    classpath "com.android.tools.build:gradle:4.2.2"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
    jcenter() // Warning: this repository is going to shut down soon
    }
  }

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