尝试为android编译示例项目,但gradle抱怨它无法找到 com.android.support:appcompat-v7:27。+ 依赖项。这是有道理的,因为我的本地回购只有 26.0.0-alpha1 和更旧。尝试将maven.google.com或google()添加到build.gradle但是没有做任何事情。然而,通过浏览器查看谷歌的maven repo我可以清楚地看到它有我需要的东西!也许我需要禁用本地回购或其他东西,但是如何?..
输出 gradle build
,版本为4.4.1:
> Could not find any version that matches com.android.support:appcompat-v7:27.+.
Versions that do not match:
26.0.0-alpha1
25.3.1
25.3.0
25.2.0
25.1.1
+ 31 more
Searched in the following locations:
file:/D:/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml
file:/C:/Users/xxx/IdeaProjects/MyApplication/sdk-manager/com/android/support/appcompat-v7/maven-metadata.xml
file:/C:/Users/xxx/IdeaProjects/MyApplication/sdk-manager/com/android/support/appcompat-v7/
Required by:
project :app
答案 0 :(得分:0)
显然你需要添加" google()" allprojects ,而不是 buildscript 依赖项。 :^)嗯这很尴尬..
仅供将来参考(3个月后再次出现这个废话)。您希望您的顶级build.gradle看起来像(由于@Eugen Pechanec提到的原因也将它添加到buildscript中):
...
allprojects {
repositories {
jcenter()
// apparently google() can be used too, but I couldn't get it to work
// google()
maven { url 'https://maven.google.com' }
}
}
...