当我想要安装Google Play服务15.0.2(因为15.0.0会出现dexing错误,我不知道原因),我在Gradle中遇到了以下错误:
Failed to resolve: com.google.android.gms:play-services-location:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog
Failed to resolve: com.google.android.gms:play-services-basement:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog
Failed to resolve: com.google.android.gms:play-services-tasks:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog
但是我从未在任何build.gradle文件中添加这些依赖项。 如果我想通过安装按钮安装,我会遇到错误: 找不到依赖关系。
这是我的build.gradle文件:
apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 25
def DEFAULT_BUILD_TOOLS_VERSION = "25.0.2"
def DEFAULT_TARGET_SDK_VERSION = 25
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "15.0.2"
android {
compileSdkVersion project.hasProperty('compileSdkVersion') ?
project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion project.hasProperty('buildToolsVersion') ?
project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion
project.hasProperty('buildToolsVetargetSdkVersionrsion') ?
project.buildToolsVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
}
}
repositories {
mavenCentral()
}
dependencies {
def googlePlayServicesVersion =
project.hasProperty('googlePlayServicesVersion') ?
project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.facebook.react:react-native:+'
compile "com.google.firebase:firebase-core:$googlePlayServicesVersion"
compile "com.google.firebase:firebase-messaging:$googlePlayServicesVersion"
compile 'me.leolin:ShortcutBadger:1.1.17@aar'
}
编辑: 我成功解决了我的问题。 实际上,在我的父级build.gradle中有一个multidex脚本,它强制更新了所有的com.gms.google到15.0.2,但正如你所说,谷歌游戏服务没有15.0.2。 我只需删除此脚本即可解决问题。