Java 无法解析 com.google.android.gms play-services-auth:11.4.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46417939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to resolve com.google.android.gms play-services-auth:11.4.0
提问by Johon smuthio
I am trying to write code for Android FirebaseUI — Auth in my android project but from last two days, I am getting errors in my current code and don't know how to fix it. trying hard but nothing happened in the right way.
我正在尝试为 Android FirebaseUI 编写代码 — 在我的 android 项目中进行身份验证,但从最近两天开始,我的当前代码出现错误,不知道如何修复。努力但没有以正确的方式发生。
here is my build.gradle(project:FriendlyChat)
这是我的 build.gradle(project:FriendlyChat)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
here is my build.gradle(Module:app)
这是我的 build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Displaying images
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.android.gms:play-services-auth:11.4.0'
testCompile 'junit:junit:4.12'
}
回答by Learning Always
Change your top level dependency gradle setting
更改您的顶级依赖项 gradle 设置
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
回答by Gabriele Mariotti
Failed to resolve com.google.android.gms play-services-auth:11.4.0 .
无法解析 com.google.android.gms play-services-auth:11.4.0 。
Add maven { url "https://maven.google.com" }
to your root level build.gradle
file
添加maven { url "https://maven.google.com" }
到您的根级别build.gradle
文件
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
This maven repo is required starting from 11.2.0.
从 11.2.0开始需要此 Maven 存储库。
You can also use the google()
shortcut but check the requirementsbefore using it.
您也可以使用google()
快捷方式,但在使用前请检查要求。
Also pay attention since you are using different version. Use the same version.
还要注意,因为您使用的是不同的版本。使用相同的版本。
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.android.gms:play-services-auth:11.4.0'
UPDATE
更新
Firebase Android SDKs and Google Play Services libraries now have independent version numbers, allowing for more frequent, flexible updates. Update the google play service gradle plugin version to latest version (at least 3.3.1).
Firebase Android SDK 和 Google Play 服务库现在具有独立的版本号,允许更频繁、更灵活的更新。将 google play 服务 gradle 插件版本更新到最新版本(至少 3.3.1)。
classpath 'com.google.gms:google-services:4.0.1'
and update the libraries to the latest version.
并将库更新到最新版本。
回答by DaniloDeQueiroz
I faced the same problem here today and just had to disable gradle offline work option on "File >> Settings >> Build, Execution, Deployment >> Gradle >> Offline work".
我今天在这里遇到了同样的问题,只需要在“文件 >> 设置 >> 构建、执行、部署 >> Gradle >> 离线工作”上禁用 gradle 离线工作选项。
回答by Kundan
This error means that google play services 11.4.0 is not installed in your android studio.
To fix this you need to change the version of the dependency to what is installed in your android studio.
For this go to : Project Structure -> Project Settings -> Modules -> Dependencies
Here click on the + sign. Find your desired dependency.You can check its version here.You can also add the dependency to your project from here.
此错误意味着您的 android studio 中未安装 google play services 11.4.0。
要解决此问题,您需要将依赖项的版本更改为您的 android studio 中安装的版本。
为此,请转到:项目结构 -> 项目设置 -> 模块 -> 依赖项
这里单击 + 号。找到你想要的依赖。你可以在这里查看它的版本。你也可以从这里将依赖添加到你的项目中。
It is always recommended that you update your google play services SDK tools from SDK manager and use the newest version.
始终建议您从 SDK 管理器更新您的 google play 服务 SDK 工具并使用最新版本。
回答by naXa
Add google()
repository to your "build.gradle" file. This gradle method is equivalent to maven { url "https://maven.google.com" }
.
将google()
存储库添加到您的“build.gradle”文件中。这种 gradle 方法等效于maven { url "https://maven.google.com" }
.
repositories {
jcenter()
google()
}
回答by Sai Gopi N
add this in your project level gradle file
将此添加到您的项目级别 gradle 文件中
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
回答by ViT-Vetal-
回答by eliasbagley
In my case I already had the google()
repository installed. I was unable to resolve the dependency until I rebooted Android Studio. My guess is it couldn't resolve due to some lingering proxy config from when I had Charles open earlier in the day.
就我而言,我已经google()
安装了存储库。在我重新启动 Android Studio 之前,我无法解决依赖关系。我的猜测是它无法解决,因为我当天早些时候打开 Charles 时有一些挥之不去的代理配置。
回答by Seyyedd Masoud Nabavi
Change your top level dependency gradle setting
更改您的顶级依赖项 gradle 设置
Open This File --> build.gradle(Project:*****)
打开这个文件 --> build.gradle(项目:*****)
and Past This Codes
和过去的代码
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Or Just Change
或者只是改变
classpath 'com.android.tools.build:gradle:2.2.2'
to
到
classpath 'com.android.tools.build:gradle:3.0.1'
回答by Anirban
In my case I've turned on gradle offline mode that's why it could not find out cached files for that version play-service or can not resolve. When I turn it on back to online everything is ok now.
在我的情况下,我打开了 gradle 离线模式,这就是为什么它无法找到该版本播放服务的缓存文件或无法解析的原因。当我将其重新打开时,现在一切正常。
Android Studio ->> File ->> Gradle ->> offline ->> uncheck
Android Studio ->> 文件 ->> Gradle ->> 离线 ->> 取消选中