我目前正在做一个学校项目并从这里提取代码 https://github.com/googlesamples/android-nearby/tree/master/connections/rockpaperscissors .我正在使用 Intellij IDEA Ultimate 2018.3。 (好吧,它基本上也是一个 Android Studio)
我在那个项目上工作了好几天,一切都正常,直到今天我发现这个 Gradle 错误:
Failed to resolve: androidx.appcompat:appcompat:1.1.0-alpha01
Show in File
Failed to resolve: com.google.android.gms:play-services-nearby:16.0.0
Install Repository and sync project
Show in File
这是我的项目级build.gradle:
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha06'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的模块 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "{my school project Id}"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'com.google.android.gms:play-services-nearby:16.0.0'
}
我做了什么来解决这个问题:
- 使 IntelliJ 失效/重启
- 重建/清理项目
- 检查了 Google Maven 存储库中可能存在的包名拼写错误
- 重新启动我的电脑
- 重新安装 Google Play 服务
更让我沮丧的是,昨天一切都很好!因此,任何帮助将不胜感激。谢谢!
最佳答案
也许您可以尝试将 build.gradle 的依赖项更改为
classpath 'com.android.tools.build:gradle:3.2.1'
关于android - Gradle 无法解析 androidx.appcompat :appcompat:1. 1.0-alpha01 和 com.google.android.gms :play-services-nearby:16. 0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53635269/