如何将firebase库添加到Android Studio中

时间:2017-07-18 04:49:48

标签: android android-studio android-gradle

我想在我的应用程序中添加以下库:

我想在我的应用程序中添加以下库:

compile 'com.google.firebase:firebase-core:11.0.0'
compile 'com.google.firebase:firebase-messaging:11.0.0'
compile 'com.google.firebase:firebase-crash:11.0.0'

但是当同步应用程序显示以下错误时:https://image.ibb.co/e7vzja/rfggtr.png

我的gradle.build文件:

apply plugin: 'com.android.application'
//apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-crash'

buildscript {
    repositories {
//      maven { url 'https://maven.fabric.io/public' }
    }

//  dependencies {
//      classpath 'io.fabric.tools:gradle:1.+'
//  }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "ir.kindnesswall"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0.0"
    }

    signingConfigs {
        release {
            storeFile file("key.jks")
            storePassword ""
            keyAlias ""
            keyPassword ""
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            signingConfig signingConfigs.release
        }
    }

    dataBinding {
        enabled = true
    }
}

// run ./gradlew :app:firebaseUploadReleaseProguardMapping from project directory that has gradlew.bat
setProperty("FirebaseServiceAccountFilePath", rootProject.rootDir.absolutePath + FirebaseServiceAccountFilePath)

dependencies {
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'

    compile('com.github.afollestad.material-dialogs:core:0.8.5.6@aar') {
        transitive = true
    }

//  compile('com.mikepenz:materialdrawer:5.0.8@aar') {
//      transitive = true
//  }
    compile 'com.github.traex.rippleeffect:library:1.3'

    compile 'com.jakewharton:butterknife:7.0.1'

    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'

    compile 'com.github.rey5137:material:1.2.1'

    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'

//  compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

//  compile 'com.roughike:bottom-bar:1.4.0.1'

    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'


    compile 'com.google.firebase:firebase-core:11.0.0'
//  compile 'com.google.firebase:firebase-messaging:10.2.6'
    compile 'com.google.firebase:firebase-messaging:11.0.0'
    compile 'com.google.firebase:firebase-crash:11.0.0'

    compile 'com.github.Aspsine:MultiThreadDownload:920fd6f670'

    compile 'com.squareup.picasso:picasso:2.5.2'

    compile 'com.heinrichreimersoftware:material-intro:1.6.2'

}

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

如何解决此错误?

3 个答案:

答案 0 :(得分:0)

如果您使用的是Android Studio 2.2或更高版本,则可以按照android studio中提供的帮助获取工具,而不是选择firebase及其产品,它将帮助您获取所有信息。有关详细信息,请参阅此Link

答案 1 :(得分:0)

compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'

尝试使用这些版本。

答案 2 :(得分:0)

首先,您必须在Android SDK中添加Google Play服务和Google存储库,然后在build.gradle(项目)中添加此classpath 'com.google.gms:google-services:3.0.0'