【发布时间】:2021-03-16 19:08:27
【问题描述】:
我的 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
【问题讨论】:
-
您是否已经尝试将其“单独”添加为
implementation "androidx.viewpager2:viewpager2:1.0.0"? -
是的,我试过了,又遇到了同样的错误。
-
您是否检查了链接dl.google.com/dl/android/maven2/androidx/viewpager2/viewpager2/… 是否在您的机器上工作?
-
这是 viewpager2-1.0.0.aar 下载链接。我下载了它并手动将其添加到项目中,但我再次收到此错误。
标签: android android-studio android-gradle-plugin android-viewpager android-viewpager2