我尝试在我的android项目中修复对谷歌播放服务的依赖。它已经有效,但现在已经坏了。我认为这发生在Android Studio beta版和发行版之间。
这是build.gradle文件中的依赖项:
dependencies {
compile 'com.google.android.gms:play-services:6.5.87'
}
Android Studio能够自动完成版本字符串:'6.5.87'所以我认为它知道如何解决依赖关系。但事实并非......这就是我所想的:
但是如果我尝试执行gradle项目同步,我仍然会收到此错误:
错误:找不到com.google.android.gms:play-services:6.5.87。 在以下位置搜索: 文件:/ C:/Users/MyName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom 文件:/ C:/Users/MaName/.m2/repository/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom https://repo1.maven.org/maven2/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.pom https://oss.sonatype.org/content/repositories/releases/com/google/android/gms/play-services/6.5.87/play-services-6.5.87.jar 要求: 代码:机器人:1.0
更新
Gradle正在“file:/ C:/Users/MyName/.m2/repository/”中搜索但它应该使用 “file:/ C:/ Users / MyName / AppData \ Local \ Android \ sdk \ extras \ google \ m2repository”..我不知道为什么这是错误的以及如何解决它..
更新2
我使用此解决方法修复了它:
repositories {
def androidHome = System.getenv("ANDROID_HOME")
maven { url "$androidHome/extras/android/m2repository/" }
maven { url "$androidHome/extras/google/m2repository/"}
}
但我对它并不满意。有人知道我的傻瓜有什么不对吗?
答案 0 :(得分:15)
在Android SDK Manager中下载“Google Repository”
答案 1 :(得分:2)
尝试下载sdk并使用此库
compile 'com.google.android.gms:play-services:7.0.0'
答案 2 :(得分:2)
将jcenter()添加到reposetories或顶级gradle文件后我修复了问题
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}