简体   繁体   中英

ERROR: Failed to resolve: com.google.firebase:firebase-core:

Gradle sync fails while trying to build the firebase app!

ERROR: Failed to resolve: com.google.firebase:firebase-core:
Affected Modules: firebase_core

This is my project-level build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

and app level build.gradle dependencies

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.8'
    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'
}

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

EDIT: The error seems to be due to Flutter Firebase_auth plugin!

I had a similar problem. When I look at the error message in detail, I get the following message.

Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0) code here

The problem is that the same class exists in the androidx and firebase packages. Add the following options to the gradle.properties file.

android.useAndroidX=true
android.enableJetifier=true

In my case, this was solved.

In project level gradle add following

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

I believe that this issue was fixed in the 0.3.4 update of firebase_core, which is a dependency of other Flutter Firebase plugins. Try a "flutter packages upgrade" and see if that fixes it for you.

https://github.com/flutter/plugins/pull/1464/files

Looks like google-service.json file is missing or is invalid. Adding google-service.json file from the Firebase console can fix it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM