【问题标题】:Failed to resolve: com.firebase:firebase-client-android:2.3.1无法解决:com.firebase:firebase-client-android:2.3.1
【发布时间】:2015-10-13 13:39:57
【问题描述】:

我正在处理以下博客中的示例

https://www.firebase.com/blog/2015-10-01-firebase-android-app-engine-tutorial.html

添加依赖后项目编译失败

compile 'com.firebase:firebase-client-android:2.3.1'

其他依赖编译没有任何问题。

'com.android.support:appcompat-v7:23.0.1'
'compile 'com.android.support:design:23.0.1'

我哪里错了?

这是我的模块 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.tri.todoapp"
        minSdkVersion 15
        targetSdkVersion 23
        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'])
//    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.firebase:firebase-client-android:2.4.0'
}

顶级gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.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
}

【问题讨论】:

    标签: android firebase android-gradle-plugin


    【解决方案1】:

    项目无法编译,因为版本 2.3 不存在。您应该使用 2.3.1:

    compile 'com.firebase:firebase-client-android:2.3.1'
    

    或最新的 2.4.0:

    compile 'com.firebase:firebase-client-android:2.4.0'
    

    您可以在这里找到更多信息:
    https://www.firebase.com/docs/android/quickstart.html

    【讨论】:

    • 抱歉打错了,我实际使用的是 2.3.1 ,
    • @Code_Yoga 请更新您的答案并添加您的项目和应用程序 build.gradle 否则我们无法帮助您
    • 更新了我的问题,添加了完整的 build.gradle 文件
    • 能否也添加项目或顶级build.gradle
    • 添加了顶级 build.gradle
    【解决方案2】:

    我们谈论的是 Google api 版本,而没有提及 Google Repository 版本。 这里的实际问题是您的 Google 存储库并不“知道”你们所有人都尝试使用的 firebase 版本。

    我在关注official firebase documentation 时遇到了同样的错误

    我的应用级 build.gradle 文件如下所示:

    apply plugin: 'com.android.application'
    android {
      // ...
    }
    
    dependencies {
      // ...
      compile 'com.google.firebase:firebase-core:10.2.1'
      compile 'com.google.firebase:firebase-messaging:10.2.1'
    
    }
    apply plugin: 'com.google.gms.google-services'
    

    我的 Google 存储库版本是 44

    你可以检查你的 SDK 管理器>Android SDK> SDK 工具(选项卡)

    最新版本是 46(在撰写本文时)

    我已更新到最新的 Google Repository 版本,问题已解决!

    您可以通过检查 SDK 工具选项卡下的“Google Repository”进行更新,然后单击“Apply”将 Google Repository 更新到最新版本

    如果您不希望更新您的 Google 存储库版本,您仍然可以通过稍微降低您的 firebase api 版本来解决该问题。 就我而言,将应用级 build.gradle 文件更改为以下内容也可以解决我的问题:

    apply plugin: 'com.android.application'
    android {
      // ...
    }
    
    dependencies {
      // ...
      compile 'com.google.firebase:firebase-core:10.2.0'
      compile 'com.google.firebase:firebase-messaging:10.2.0'
    
    }
    apply plugin: 'com.google.gms.google-services'
    

    firebase 版本已从 10.2.1 降至 10.2.0

    这是可行的,因为 Google 存储库版本 44 已知 10.2.0。

    我希望这个答案对未来的许多人有所帮助。

    【讨论】:

      【解决方案3】:

      您需要将 Firebase 添加到两个模块:

      • android 模块:您应该使用项目结构中出现的“添加 Firebase”复选框,该复选框会将 2.3.1 添加到 android 应用程序中。

      • 后端模块需要 2.4 才能在应用引擎中运行,这些步骤需要您手动添加依赖项。 在这种情况下,请确保您添加的是 jvm 客户端——而不是应用引擎的“android”客户端。 编译'com.firebase:firebase-client-android:2.4.0'

      【讨论】:

        【解决方案4】:

        这是因为这个版本

        compile 'com.firebase:firebase-client-android:2.3'
        

        不存在。

        您可以使用以下之一:

        compile 'com.firebase:firebase-client-android:2.4.0'
        compile 'com.firebase:firebase-client-android:2.3.1'
        compile 'com.firebase:firebase-client-android:2.3.0'
        

        注意。

        compile 'com.firebase:firebase-client-android:2.3.0'
        

        不同于

        compile 'com.firebase:firebase-client-android:2.3'
        

        你可以找到full list in maven:

        【讨论】:

        • 抱歉错字,我实际上使用的是 2.3.1。我在标题中正确地提到了它。我现在已经编辑了描述。我什至用过 2.4.0。 ,在我的情况下没有任何效果。
        • @Code_Yoga 没有任何效果...这是什么意思?在主题中,问题是“无法解决”。如果您有其他问题,请打开一个新问题。
        • “没有任何效果”是指 2.3.1 和 2.4.0 都没有编译,我得到相同的“无法解决”
        【解决方案5】:

        使用

        compile 'com.firebase:firebase-client-android:+'
        

        为我工作。

        【讨论】:

          【解决方案6】:

          我今天遇到了完全相同的问题,但版本是 2.4.1。但是,我无法打开链接 l jcenter.bintray.com/com/firebase/firebase-client-android/2.4.1/ 如 Mattia Maestrini 所述。

          我的解决方案:停用我的 VPN,然后它就起作用了。

          【讨论】:

            【解决方案7】:

            看起来这是一个 dex 限制错误。添加 Firebase SDK 一定让我超出了限制,要解决这个问题,我必须在我的 app:build.gradle 文件的 defaultConfig 部分添加 multiDexEnabled true 以及 compile 'com. android.support:multidex:1.0.0' 在依赖项中

            这是我的毕业典礼

            项目分级

            // Top-level build file where you can add configuration options common to all sub-projects/modules.
            
            buildscript {
                repositories {
                    jcenter()
                }
                dependencies {
                    classpath 'com.android.tools.build:gradle:1.5.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
            }
            

            gradle 模块应用

            apply plugin: 'com.android.application'
            
            android {
                compileSdkVersion 23
                buildToolsVersion "23.0.2"
            
                defaultConfig {
                    applicationId "com.tranetech.openspace.firebasedemo"
                    minSdkVersion 16
                    targetSdkVersion 23
                    versionCode 1
                    versionName "1.0"
                    multiDexEnabled true
                }
                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'])
                testCompile 'junit:junit:4.12'
                compile 'com.android.support:appcompat-v7:23.2.1'
                compile 'com.firebase:firebase-client-android:2.5.2+'
                compile 'com.firebaseui:firebase-ui:0.3.1'
                compile 'com.android.support:multidex:1.0.0'
            }
            

            【讨论】:

              【解决方案8】:

              我不确定您是否仍在使用该项目,但我也遇到了同样的问题,我的解决方案是

              在你的 build.gradle 中(在 app 文件夹之外),添加

              buildscript {
                  repositories {
                      jcenter()
                  }
                  dependencies {
                      ////
                      classpath 'com.google.gms:google-services:3.0.0'
              
                      // NOTE: Do not place your application dependencies here; they belong
                      // in the individual module build.gradle files
                  }
              }
              

              然后在你的模块 build.gradle 中添加

              dependencies {
                  compile fileTree(dir: 'libs', include: ['*.jar'])
                  testCompile 'junit:junit:4.12'
                  compile 'com.android.support:appcompat-v7:23.+'
                  compile 'com.android.support:design:23.+'
                  compile 'com.google.firebase:firebase-core:9.2.1'
                  compile 'com.google.firebase:firebase-database:9.2.1'
                  compile 'com.firebase:firebase-client-android:2.4.0'
              }
              

              应用插件:

              'com.google.gms.google-services'// <- this code
              

              最后,别忘了下载google-services.json放在你的app文件夹中,路径应该是\yourapplication\app,你也可以参考这个链接下载google-services.json 文件。 Download a configuration file

              【讨论】:

                【解决方案9】:

                编译已弃用。你应该使用:

                implementation 'com.firebase:firebase-client-android:2.5.2'
                

                【讨论】:

                  猜你喜欢
                  • 2018-11-06
                  • 2017-06-27
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2023-04-06
                  • 1970-01-01
                  • 2014-01-15
                  相关资源
                  最近更新 更多