找不到插件项目:firebase_core_web [英] Plugin project :firebase_core_web not found
问题描述
我尝试将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
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
}
}
注意:
您需要使用在扑扑中使用Firebase时> minSdkVersion 23
。
来自文档:
默认情况下,Flutter支持Android SDK v16(Jelly Bean,2012年发布) ,但multidex不能真正与Jelly Bean配合使用(尽管有可能)。配置Jelly Bean可以工作超出了本代码实验室的范围,因此我们将最低目标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。
- 保存文件。
升级后,它应该可以正常工作。当您创建任何新的Flutter项目时,会向您提供 settings.gradle
文件。供参考,这是您的 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
}
说明( settings.gradle
:
Gradle
是用于Android项目的构建工具,就像 ant
或 maven
,它使用时髦的语言或kotlin编写脚本。在这种情况下,上面的代码是使用 groovy
编写的,并且由于 groovy
是 jvm
语言,则它可以使用 Java
库。因此基本上 include':app'
会将项目添加到构建中(通常,您可以省略方法的括号)。
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 {名称,路径->
这基本上是一个迭代,它将插件名称和插件路径添加到文件 .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屋!