我有Android项目,当运行./gradlew dependencies
命令时,我收到以下错误,我无法弄清楚如何使用Google Play服务8.4.0。 (8.3.0作品)
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.google.android.gms:play-services:8.4.0.
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
https://jcenter.bintray.com/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
https://maven.fabric.io/public/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
https://maven.fabric.io/public/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
https://zendesk.artifactoryonline.com/zendesk/repo/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
https://zendesk.artifactoryonline.com/zendesk/repo/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
https://repo1.maven.org/maven2/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
https://repo1.maven.org/maven2/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
file:/usr/local/android-sdk-linux/extras/android/m2repository/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
file:/usr/local/android-sdk-linux/extras/android/m2repository/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
file:/usr/local/android-sdk-linux/extras/google/m2repository/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.pom
file:/usr/local/android-sdk-linux/extras/google/m2repository/com/google/android/gms/play-services/8.4.0/play-services-8.4.0.jar
以下是app gradle文件的外观。
dependencies {
....
compile 'com.google.android.gms:play-services:8.4.0'
....
}
我已经尝试将以下内容放在项目gradle文件中,但没有帮助。
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
有人可以帮助我进一步调试吗?
答案 0 :(得分:8)
配置项目':app'。
时出现问题无法解析配置':app:_debugCompile'的所有依赖项。 找不到com.google.android.gms:play-services:8.4.0。
发布您的总build.gradle
'com.android.tools.build:gradle:2.0.0-alpha3'
最后
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId ""
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
答案 1 :(得分:5)
看起来Google在Google Repository
下包含了许多库。 通过SDK管理器安装Google Repository
和Android Support Repository
,gradle应该能够解析这些库。这是我的gradle.build
文件进行比较:
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.application'
android {
repositories { jcenter() }
compileSdkVersion 24
buildToolsVersion '24.0.1'
dependencies {
compile 'com.google.android.gms:play-services:9.2.1'
}
}
答案 2 :(得分:2)
我也有同样的问题。这将是Android SDK中以下软件包的缺失:
如果您使用的是Android SDK command line tools sdkmanager
,则可以运行以下命令来安装相关的软件包:
sdkmanager "extras;android;m2repository"
sdkmanager "extras;google;m2repository"
sdkmanager "extras;google;google_play_services"
答案 3 :(得分:1)
你需要
buildToolsVersion "23.0.2"
您已在sdk manager中下载
并在build.gradle
我在build.gradle项目方面使用它
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
答案 4 :(得分:0)
还会将此行添加到您的应用级代码
apply plugin: 'com.google.gms.google-services'
dependencies {
....
compile 'com.google.android.gms:play-services:8.4.0'
....
}