插件项目:firebase_core_web 未找到 [英] Plugin project :firebase_core_web not found

查看:27
本文介绍了插件项目:firebase_core_web 未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将 Android 项目连接到 Firebase,但在将以下内容添加到 pubsec.yaml 时出现此错误:

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

当我运行 gradle 但它不工作时

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.

有什么解决办法吗

推荐答案

在您的 android/app/build.gradle 中,更新以下内容:

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

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

进入:

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


注意:

在flutter中使用firebase时需要使用minSdkVersion 23.

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

来自文档:

默认情况下,Flutter 支持 Android SDK v16(Jelly Bean,2012 年发布),但 multidex 并不能真正与 Jelly Bean 一起使用(尽管有可能).配置 Jelly Bean 工作超出了本 Codelab 的范围,因此我们将最低目标 SDK 版本从 v16 更改为 v21(Lollipop,2014 年发布).

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).

更改最低目标 SDK 版本:

To change the minimum target SDK version:

  • 打开 android/app/build.gradle,然后找到显示 minSdkVersion 16 的行.
  • 将该行更改为 minSdkVersion 21.
  • 保存文件.

升级后,它应该可以正常工作.settings.gradle 文件在您创建任何新的 Flutter 项目时提供给您.作为参考,您的 settings.gradle 文件应该是这样的(默认文件没有变化):

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

说明:

Gradle 是一个用于android 项目的构建工具,就像antmaven 一样,它使用groovy 语言或kotlin 进行脚本编写.在这种情况下,上面的代码是使用 groovy 编写的,并且由于 groovy 是一种 jvm 语言,因此它可以使用 Java 库.所以基本上 include ':app' 会将项目添加到构建中(在 groovy 中,您可以省略方法的括号).

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).

这一行:

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

正在获取您在机器中创建的 flutter 项目的路径.供参考:

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

这一行:

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

将在您的 flutter 项目的根目录下创建一个名为 .flutter-plugins 的空文件.然后 plugins.each{ name, path -> 这基本上是一个迭代,将插件名称和插件的路径添加到文件 .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 文件:

# 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/

这篇关于插件项目:firebase_core_web 未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆