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

时间:2021-10-10 20:17:48

I tried to integrate the Firebase in my app by following the steps given on the official site. But I am getting some error regarding the Google Play Services.

我尝试按照官方网站上给出的步骤在我的应用程序中集成Firebase。但是我在谷歌播放服务上犯了一些错误。

Here is my build.gradle:

这是我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'

Here is my project/build.gradle:

这是我的项目/ 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
}

I have added the google-service.json file also in my app folder. I am getting this error

我添加了google服务。json文件也在我的app文件夹中。我得到了这个错误

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

Can someone please tell me how can I fix it.

有人能告诉我怎么修理吗?

2 个解决方案

#1


1  

I suggest that Go to Android SDK Manager and install the latest version of this two libraries Google Play Services,Google Repository

我建议去Android SDK管理器安装这两个库的最新版本谷歌播放服务,谷歌储存库

#2


0  

If you use Android studio 2.2 than go to the tools from top menu and click on firebase..than follow the instruction. Or your Gradle

如果你使用的是Android studio 2.2,那么点击顶部菜单的工具,点击firebase。比遵循指令。或者你的它

com.google.firebase:firebase-core:9.6.1 change to com.google.firebase:firebase-core:9.0.1

com.google.firebase:firebase-core:9.6.1改变com.google.firebase:firebase-core:9.0.1

And for json file please follow firebase instruction given through their developer site.

对于json文件,请遵循通过他们的开发站点给出的firebase指令。

This link can help you for json file : https://firebase.google.com/docs/server/setup

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

#1


1  

I suggest that Go to Android SDK Manager and install the latest version of this two libraries Google Play Services,Google Repository

我建议去Android SDK管理器安装这两个库的最新版本谷歌播放服务,谷歌储存库

#2


0  

If you use Android studio 2.2 than go to the tools from top menu and click on firebase..than follow the instruction. Or your Gradle

如果你使用的是Android studio 2.2,那么点击顶部菜单的工具,点击firebase。比遵循指令。或者你的它

com.google.firebase:firebase-core:9.6.1 change to com.google.firebase:firebase-core:9.0.1

com.google.firebase:firebase-core:9.6.1改变com.google.firebase:firebase-core:9.0.1

And for json file please follow firebase instruction given through their developer site.

对于json文件,请遵循通过他们的开发站点给出的firebase指令。

This link can help you for json file : https://firebase.google.com/docs/server/setup

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