在应用中集成Firebase:“找不到com.google.firebase:firebase-core:9.6.1”

时间:2016-10-12 04:46:32

标签: android firebase

我尝试按照官方网站上的步骤将Firebase集成到我的应用中。但是我对Google Play服务收到了一些错误。

这是我的build.gradle:

    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    apply plugin: 'android-apt'
    apply plugin: 'newrelic'

    android {
        compileSdkVersion 23
        buildToolsVersion '23.0.2'

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }

    defaultConfig {

        /**
         * applicationId uniquely identifies the package for publishing.
         * However, your source code should still reference the package name
         * defined by the package attribute in the main/AndroidManifest.xml file.
         */

        applicationId "com.mobiefit.walk"

        // Defines the minimum API level required to run the app.
        minSdkVersion 15

        // Specifies the API level used to test the app.
        targetSdkVersion 19

        versionCode 10
        versionName "1.3.3"


        multiDexEnabled true
        dexOptions {
            javaMaxHeapSize "4g"
        }
        lintOptions {
            checkReleaseBuilds false
            abortOnError false
        }

    }

    signingConfigs
            {
                release {
                    storeFile file("release_build_keystore.jks")
                    storePassword "mobiefit"
                    keyAlias "mobiefit-walk-release"
                    keyPassword "mobiefit"
                }
                debug {
                            storeFile file("debug_build_keystore.jks")
                            storePassword "mobiefit"
                            keyAlias "debug-build-keystore"
                            keyPassword "mobiefit"
                        }
            }


    buildTypes {

        /**
         * By default, Android Studio configures the release build type to enable code
         * shrinking, using minifyEnabled, and specifies the Proguard settings file.
         */
        release {
            signingConfig signingConfigs.release
            minifyEnabled true   // Enables code shrinking for the release build type.P
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "facebookAppId", "640495806088842"
        }
        debug {
         /*   ext.enableCrashlytics = false//for Crashlytics */
            signingConfig signingConfigs.debug
            applicationIdSuffix ".debug"
            minifyEnabled false // Disables code shrinking for the debug build type.
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "facebookAppId", "215337192218344"
        }
    }

}

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }
    dependencies {
        // The Fabric Gradle plugin uses an open ended version to react
        // quickly to Android tooling updates
        classpath 'io.fabric.tools:gradle:1.+'
        classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
    }
}
apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'

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


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/commons-collections4-4.0.jar')
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile files('libs/graphview-3.1.jar')
    compile files('libs/httpcore-4.3.1.jar')
    testCompile 'junit:junit:4.12'
    compile project(':progresslibrary')
    compile files('libs/gson-2.6.2.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.1@aar') {
        transitive = true;
    }
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.hrules:charter:1.4.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.hrules:charter:1.4.0'
    compile 'com.amazonaws:aws-android-sdk-core:2.+'
    compile 'com.amazonaws:aws-android-sdk-s3:2.+'



    compile 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.snappydb:snappydb-lib:0.5.2'
    compile 'com.google.android.gms:play-services-auth:9.0.0'
    compile 'com.google.android.gms:play-services-plus:9.0.0'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.android.gms:play-services-location:9.0.0'
    compile 'com.wdullaer:materialdatetimepicker:2.2.0'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'

    compile 'com.shamanland:fab:0.0.8'

    compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
    compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'

    compile 'com.google.android.gms:play-services-analytics:9.0.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'





    compile 'com.android.support:design:23.2.1'
    compile 'com.android.support:support-v4:23.2.1'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:cardview-v7:23.2.1'
    compile 'com.android.support:appcompat-v7:23.0.1'

    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'
    compile 'com.google.android.gms:play-services-analytics:9.0.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'
    compile 'org.jsoup:jsoup:1.9.1'
    compile 'com.flurry.android:analytics:6.2.0'
    compile 'com.google.android.gms:play-services-fitness:9.0.0'
    compile 'com.google.android.gms:play-services-appindexing:9.0.0'
    compile 'com.github.danielemaddaluno.androidupdatechecker:library:1.0.2'

    compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.android.support:recyclerview-v7:23.2.1'
    compile 'com.newrelic.agent.android:android-agent:5.+'

    compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'

    // segment

    compile('com.segment.analytics.android:analytics-core:+') {
        transitive = true
    }
    // firebase

    compile 'com.google.firebase:firebase-core:9.6.1'
    compile 'com.google.firebase:firebase-crash:9.6.1'
    compile 'com.google.firebase:firebase-messaging:9.6.1'
    compile 'com.google.firebase:firebase-invites:9.6.1'

}

android {
    packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
    }
}

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

这是我的项目/ build.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:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我在我的app文件夹中也添加了google-service.json文件。我收到此错误

Error:Could not find com.google.firebase:firebase-core:9.6.1.
Required by:
    mobiefitwalk:app:unspecified

有人可以告诉我如何解决它。

2 个答案:

答案 0 :(得分:1)

我建议转到Android SDK Manager并安装最新版本的这两个库Google Play Services,Google Repository

答案 1 :(得分:0)

如果你使用的是Android工作室2.2而不是从顶部菜单进入工具并点击firebase ..请按照说明进行操作。或者你的Gradle

com.google.firebase:firebase-core:9.6.1更改为com.google.firebase:firebase-core:9.0.1

对于json文件,请按照其开发者网站提供的firebase说明进行操作。

此链接可以帮助您获取json文件:https://firebase.google.com/docs/server/setup