Plugin project :firebase_core_web not found

Alex Ali picture Alex Ali · May 11, 2020 · Viewed 40.5k times · Source

I try to connect Android project to Firebase but I get this error as I added the following to pubsec.yaml:

firebase_auth: ^0.16.0
cloud_firestore: ^0.13.5

when I gradle run and it is not working

Plugin project :firebase_core_web not found. Please update settings.gradle.
Plugin project :firebase_auth_web not found. Please update settings.gradle.
Plugin project :cloud_firestore_web not found. Please update settings.gradle.

Is there any solution for it

Answer

Peter Haddad picture Peter Haddad · May 11, 2020

In your android/app/build.gradle, update the following:

android {
    // ...
    defaultConfig {
        // ...
        minSdkVersion 16
    }
}

into:

android {
    // ...
    defaultConfig {
        // ...
        minSdkVersion 23
    }
}

Note:

You need to use minSdkVersion 23 when using firebase in flutter.

From the docs:

By default, Flutter supports Android SDK v16 (Jelly Bean, released 2012), but multidex doesn't really work with Jelly Bean (though, it's possible). Configuring Jelly Bean to work is beyond the scope of this codelab, so we'll change the minimum target SDK version from v16 to v21 (Lollipop, released 2014).

To change the minimum target SDK version:

  • Open android/app/build.gradle, then find the line that says minSdkVersion 16.
  • Change that line to minSdkVersion 21.
  • Save the file.

After upgrading, it should work fine. The settings.gradle file is provided to you when you create any new flutter project. For reference, this is how your settings.gradle file should be (default file no changes):

include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    include ":$name"
    project(":$name").projectDir = pluginDirectory
}

https://github.com/PeterHdd/Firebase-Flutter-tutorials/blob/master/firebase_storage_tutorial/android/settings.gradle


Explanation of settings.gradle:

Gradle is a build tool used for android projects, just like ant or maven, it uses groovy language or kotlin for scripting. In this case the above code is written using groovy and since groovy is a jvm language then it is able to use Java libraries. So basically include ':app' will add the project to the build(in groovy you can omit parenthesis for a method).

This line:

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

is getting the path to the flutter project that you created in your machine. For reference:

https://docs.gradle.org/current/javadoc/org/gradle/api/initialization/ProjectDescriptor.html#getProjectDir-- https://docs.oracle.com/javase/8/docs/api/java/io/File.html#toPath-- https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html

This line:

def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')

Will create an empty file called .flutter-plugins, under the root of your flutter project. Then plugins.each{ name, path -> this is basically an iteration that will add the plugin name and the path of the plugin to the file .flutter_plugins, if the plugin is not found in that file you get the error in this question

.flutter-plugins file:

# This is a generated file; do not edit or check into version control.
cloud_firestore=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.13.6/
cloud_firestore_web=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-0.1.1+2/
firebase_auth=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.16.1/
firebase_auth_web=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-0.1.2/
firebase_core=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.4.4+3/
firebase_core_web=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-0.1.1+2/
firebase_database=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/firebase_database-3.1.5/
firebase_storage=/Users/<users>/.pub-cache/hosted/pub.dartlang.org/firebase_storage-3.1.5/