【问题标题】:Android build error com.google.firebase:firebase-core:17.0.0Android 构建错误 com.google.firebase:firebase-core:17.0.0
【发布时间】:2018-05-28 02:43:45
【问题描述】:

我在构建时遇到了问题。我添加了构建 firebase 核心 16.0.0,但是在构建时,这是构建 firebase 核心 17.0.0。为什么它构建 17.0.0。我检查 android https://firebase.google.com/docs/android/setup#available_libraries,现在版本 16.0.0,我必须删除构建项目,但这并不成功。 你能帮助我吗?谢谢。

当我增加版本构建时

  classpath 'com.google.gms:google-services:4.0.1' // google-services plugin

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    //them multiDexEnabled = true
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'

    // butter knife.
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    // gson.
    implementation 'com.google.code.gson:gson:2.8.2'

    // image loading.
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
    implementation "com.github.bumptech.glide:okhttp3-integration:4.7.1"
    implementation 'com.github.bumptech.glide:annotations:4.7.1'

    //com.squareup.retrofit2
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'

    //com.squareup.okhttp3
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'

    //io.reactivex.rxjava2
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.13'

    // keyboard keyboardvisibilityevent
    implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'

    // Cloud Messaging
    implementation 'com.google.firebase:firebase-messaging:17.0.0'

    //Analytics
    implementation 'com.google.firebase:firebase-core:16.0.0'

    //Invites and Dynamic Links
    implementation 'com.google.firebase:firebase-invites:16.0.0'

    //AdMob
    implementation 'com.google.firebase:firebase-ads:16.0.0'

    implementation 'com.firebaseui:firebase-ui-database:3.1.1' // No trouble in compiling
    implementation 'com.google.firebase:firebase-auth:16.0.1'

    // ViewModel and LiveData
    implementation 'android.arch.lifecycle:extensions:1.1.1'

    //room Save data in a local database using Room
    implementation 'android.arch.persistence.room:runtime:1.1.0'
    annotationProcessor "android.arch.persistence.room:compiler:1.1.0"

    //push OneSignal
    implementation 'com.onesignal:OneSignal:3.8.3'

    //gmc
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'

    //palette
    implementation 'com.android.support:palette-v7:27.1.1'

    //loading
    implementation 'com.wang.avi:library:2.1.3'

    //crop image
    implementation 'com.isseiaoki:simplecropview:1.1.7'

    //exoplayer-textureview
    implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
    implementation 'com.google.android.exoplayer:extension-ima:2.7.3'

    //facebook .
    implementation 'com.facebook.android:facebook-android-sdk:4.29.0'

    //facebook ads
    implementation 'com.facebook.android:audience-network-sdk:4.28.1'

    //no name :)
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
}

【问题讨论】:

    标签: android android-gradle-plugin android-build


    【解决方案1】:

    首先,添加 build.gradle 文件,以包含 google-services 插件和 Google 的 Maven 存储库:

    buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:4.0.1' // google-services 
    plugin
    }
    }
    
     allprojects {
    // ...
    repositories {
        // ...
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
     }
    

    在文件底部添加 apply plugin 行以启用 Gradle 插件:

    apply plugin: 'com.android.application'
    
    android {
     // ...
     }
    
     dependencies {
      // ...
     implementation 'com.google.firebase:firebase-core:16.0.0'
    
      // Getting a "Could not find" error? Make sure you have
      // added the Google maven respository to your root build.gradle
      }
    
      // ADD THIS AT THE BOTTOM
      apply plugin: 'com.google.gms.google-services'
    

    您还应该为要使用的 Firebase SDK 添加依赖项。我们建议从 com.google.firebase:firebase-core

    开始

    【讨论】:

      【解决方案2】:

      我已经解决了问题:导入一个信号

      buildscript {
          repositories {
              maven { url 'https://plugins.gradle.org/m2/'}
          }
          dependencies {
              classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.10.1'
          }
      }
      apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
      
      repositories {
          maven { url 'https://maven.google.com' }
      }
      

      【讨论】:

      • 这解决了我在项目中的问题。
      【解决方案3】:

      删除implementation 'com.google.firebase:firebase-core:16.0.0' 并将implementation 'com.google.firebase:firebase-database:10.0.0' 用于firebase 数据库,它将解决您的问题。

      【讨论】:

        【解决方案4】:

        为了解决这个问题,我遵循了 Google firebase 集成指南,并在我的 app/build.gradle 和 project/build.gradle 中进行了以下更改

        Follow this link if you have any doubts

        https://firebase.google.com/docs/android/setup

        app/build.gradle

        的变化
        implementation 'com.google.android.gms:play-services-base:15.0.2'
        implementation "com.google.firebase:firebase-core:16.0.1"
        implementation "com.google.firebase:firebase-messaging:17.4.0"
        

        Project/build.gradle

        的变化

        repositories {
        
                google()
                jcenter()
                mavenCentral()
                maven {
                    url 'https://maven.fabric.io/public'
                }
            }
            dependencies {
                classpath 'com.android.tools.build:gradle:3.1.4'
                classpath 'com.google.gms:google-services:4.2.0'// // google-services plugin it should be latest if you are using firebase version 16.0 +
               
            }
            allprojects {
            repositories {
                 google()// add it to top instead of bottom or somewhere in middle
                mavenLocal()
                mavenCentral()
                maven {
                    url 'https://maven.google.com'
                }
               
                jcenter()
                maven {
                    // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                    url "$rootDir/../node_modules/react-native/android"
                }
                
            }
        }

        【讨论】:

          【解决方案5】:

          将 google maven 存储库添加到您的应用根 build.gradle 文件

          查看文档: Click here

          如果它解决了你的问题,请告诉我

          【讨论】:

          • 你要我在底部添加一行吗? .我之前添加过,但仍然出错//在底部添加此应用插件:'com.google.gms.google-services'
          • 会有根 gradle 文件,你也必须根据文档编辑它
          • 你的意思是:maven { url "maven.google.com" // Google 的 Maven 仓库 }
          • 该文档适用于版本 11.8.0。将依赖项更新到较高版本时,它不起作用,在我的情况下,我收到了 Failed to resolve: firebase-messaging 错误,较低版本不会出现该错误
          猜你喜欢
          • 2019-03-25
          • 2019-11-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-02-25
          • 2018-11-21
          • 1970-01-01
          相关资源
          最近更新 更多