【发布时间】:2018-05-10 17:02:36
【问题描述】:
当我想安装 Google play services 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。 我刚刚删除了这个脚本,它工作了
【问题讨论】:
-
而不是导入所有谷歌服务,因为方法的数量导致dex错误,我建议只实现你将在你的应用程序中使用的那些
-
你找到解决方案了吗@Psyycker?
-
我终于可以解决我的问题,请参阅编辑以了解我是如何做到的。 ADM 回答有助于理解为什么我无法下载 google play services 15.0.2
标签: android firebase android-gradle-plugin build.gradle