【问题标题】:Failed to resolve: com.google.firebase:firebase-auth:11.0.2无法解决:com.google.firebase:firebase-auth:11.0.2
【发布时间】:2017-07-21 06:35:38
【问题描述】:

我刚刚更新了 sdk、google play services 和 google repository,但还是出现了这个错误。请帮忙,我想集成使用电话号码的身份验证。

SDK Manager

Logcat

Build.gradle 模块:项目

    // Top-level build file where you can add configuration options common to all sub-projects/module
return
 buildscript {
    ext.kotlin_version = '1.1.3-2'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:3.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

Build.gradle 模块:应用程序

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.*****"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.google.firebase:firebase-auth:11.0.2'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

}

apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 请在 bot 上发布您的应用级别和项目级别的 gradle 文件
  • 发布你添加到 gradle 的 firebase 依赖项
  • 发布你的 build.gradle 文件。
  • @LucaRossi,现在请检查我编辑的帖子。

标签: android firebase android-gradle-plugin firebase-authentication build.gradle


【解决方案1】:

在 Firebase 文档中它说:

收到“找不到”错误?确保你有 Android SDK 管理器中最新的 Google 存储库

更新 Google Repository 也应该有助于解决 Failed to resolve 问题(在撰写这些行时,Google Repository 版本为 57)。

所以解决这个问题应该相当简单。以下是您应该采取的步骤:

  1. 打开 SDK 管理器。
  2. 选择顶部选项卡上的 SDK 工具。
  3. 向下滚动,在 Support Repository 下选择 Google Repository。
  4. 点击确定按钮。
  5. 安装完成后,将 Firebase 依赖项版本更改为 11.0.2。
  6. 点击“立即同步”按钮。
  7. 享受 Firebase =)

【讨论】:

  • 没有Support Repository select Google Repository.
  • 嗨@West,我刚刚检查了一下,似乎它被谷歌出于某种原因删除了......
【解决方案2】:

好像你忘了包含谷歌播放服务插件添加这些代码行

应用级分级

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    ...
    compile "com.google.firebase:firebase-core:11.0.2"
    compile "com.google.firebase:firebase-auth:11.0.2"
    ...

}
apply plugin: 'com.google.gms.google-services'  <-- this line ath the bottom of it

项目级分级

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.1.0'  <--- This Line
}

【讨论】:

    【解决方案3】:

    // 收到“找不到”错误?确保你有 // Android SDK 管理器中最新的 Google 存储库

    【讨论】:

      【解决方案4】:

      Google 已将其新存储库从 jcenter 转移到 maven google。

      添加

      google()
      

      项目 build.gradle 中的内部存储库

      【讨论】:

        【解决方案5】:

        将 Google 自己的 maven 存储库添加到您的 build-gradle 文件中:

        repositories {
                maven {
                    url 'https://maven.google.com'
                    // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
                }
            }
        

        来源:https://developer.android.com/studio/build/dependencies.html#google-maven

        【讨论】:

          【解决方案6】:

          为我解决了设置 play-services 和 firebase 相同的版本,如下所示:

          implementation "com.google.firebase:firebase-core:11.8.0"
          implementation "com.google.firebase:firebase-messaging:11.8.0"
          implementation "com.google.firebase:firebase-database:11.8.0"
          implementation "com.google.firebase:firebase-storage:11.8.0"
          implementation "com.google.firebase:firebase-auth:11.8.0"
          implementation "com.google.firebase:firebase-config:11.8.0"
          implementation "com.google.firebase:firebase-crash:11.8.0"
          
          implementation "com.google.android.gms:play-services-maps:11.8.0"
          implementation "com.google.android.gms:play-services-location:11.8.0"
          implementation "com.google.android.gms:play-services-places:11.8.0"
          implementation "com.google.android.gms:play-services-auth:11.8.0"
          implementation "com.google.android.gms:play-services-base:11.8.0"
          

          【讨论】:

            【解决方案7】:

            尝试使用旧版本的 Auth。

            compile 'com.google.firebase:firebase-auth:10.0.1'
            

            【讨论】:

            • 旧版本不包含电话号码认证。
            猜你喜欢
            • 2016-09-19
            • 2018-02-23
            • 1970-01-01
            • 1970-01-01
            • 2022-01-10
            • 2017-07-17
            • 2017-11-15
            • 2021-06-28
            • 2019-03-30
            相关资源
            最近更新 更多