找不到 viewpager2-1.0.0.aar (androidx.viewpager2:viewpager2:1.0.0)

时间:2021-03-16 19:08:27

标签: android android-studio android-gradle-plugin android-viewpager android-viewpager2

我的 Android 项目过去构建时没有任何问题。而且我没有更改代码。但现在我有这个错误。我将 Android Studio 更新到版本 202.7188722 并创建了一个没有任何活动的新项目,但我再次收到此错误:

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find viewpager2-1.0.0.aar (androidx.viewpager2:viewpager2:1.0.0).
 Searched in the following locations:
     https://dl.google.com/dl/android/maven2/androidx/viewpager2/viewpager2/1.0.0/viewpager2- 
1.0.0.aar

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

注意:我测试了互联网连接和 HTTP 代理,没有问题。

这些是我的新项目 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.0-beta06"

    // 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
}
<块引用>

应用:

plugins {
id 'com.android.application'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
    applicationId "com.hyapp.tebgeram"
    minSdkVersion 16
    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 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
<块引用>

gradle-wrapper.properties:

#Tue Mar 16 22:03:28 IRST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。在我的情况下,它来自代理和连接问题。确保您的代理工作正常。