插件项目 :firebase_core_web 未找到.请更新设置



我已经在我的颤振项目中插入了Firebase,最近它在输出时给了我一个错误。应用程序工作正常:

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

跑步颤振医生说没有发现问题。

buuild.gradle file:

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.sample.flutter_with_firebase"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

我的pubspec.yaml:

...
dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
firebase_core: ^0.4.5
firebase_auth: ^0.14.0+5
cloud_firestore: ^0.12.9+4
provider: ^3.1.0
...

搜索这个错误,我找到了这些链接:

火碱存储教程

启用禁用 Web 支持

未找到火力核心

第一个和最后一个链接说要解决此问题,需要在设置中添加以下代码。 格拉德尔:

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 pluginDir = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ':$name'
project(':$name').projectDir = pluginDir
}

即使这样,错误仍然存在并添加了许多其他错误:

Launching libmain.dart on Android SDK built for x86 in debug mode...
Plugin project :firebase_core_web not found. Please update settings.gradle.
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:9: error: package io.flutter.embedding.engine.plugins does not exist
import io.flutter.embedding.engine.plugins.FlutterPlugin;
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:10: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodCall;
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:11: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.MethodChannel;
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:12: error: package io.flutter.plugin.common does not exist
import io.flutter.plugin.common.PluginRegistry;
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:23: error: cannot find symbol
public class FirebaseCorePlugin implements FlutterPlugin, MethodChannel.MethodCallHandler {
^
symbol: class FlutterPlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:23: error: package MethodChannel does not exist
public class FirebaseCorePlugin implements FlutterPlugin, MethodChannel.MethodCallHandler {
 ^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:26: error: cannot find symbol
private MethodChannel channel;
^
symbol:   class MethodChannel
location: class FirebaseCorePlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:35: error: package PluginRegistry does not exist
public static void registerWith(PluginRegistry.Registrar registrar) {
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:53: error: cannot find symbol
public void onAttachedToEngine(FlutterPluginBinding binding) {
^
symbol:   class FlutterPluginBinding
location: class FirebaseCorePlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:60: error: cannot find symbol
public void onDetachedFromEngine(FlutterPluginBinding binding) {
^
symbol:   class FlutterPluginBinding
location: class FirebaseCorePlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:81: error: cannot find symbol
public void onMethodCall(MethodCall call, final MethodChannel.Result result) {
^
symbol:   class MethodCall
location: class FirebaseCorePlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:81: error: package MethodChannel does not exist
public void onMethodCall(MethodCall call, final MethodChannel.Result result) {
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:36: error: cannot find symbol
final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
^
symbol:   class MethodChannel
location: class FirebaseCorePlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:36: error: cannot find symbol
final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
^
symbol:   class MethodChannel
location: class FirebaseCorePlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:52: error: method does not override or implement a method from a supertype
@Override
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:55: error: cannot find symbol
channel = new MethodChannel(binding.getBinaryMessenger(), CHANNEL_NAME);
^
symbol:   class MethodChannel
location: class FirebaseCorePlugin
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:59: error: method does not override or implement a method from a supertype
@Override
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:80: error: method does not override or implement a method from a supertype
@Override
^
C:DevelopmentAppDataRoamingPubCachehostedpub.dartlang.orgfirebase_core-0.4.5androidsrcmainjavaioflutterpluginsfirebasecoreFirebaseCorePlugin.java:82: error: illegal start of type
switch (call.method) {
^
19 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':$name:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

如何删除firebase_core_web找不到错误?

@Peter 哈达德 感谢您在帖子中给出的解释,帮助我解决这个问题。只需添加

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解决了问题

鉴于这些详细信息,我无法确定导致问题的确切原因。我开始了一个新项目,并按照本指南中的firebase_core设置进行操作。我在使用firebase_core: "0.5.2"时没有遇到任何问题

如果您仍然遇到问题,我建议您至少尝试运行flutter clean并再次flutter pub get以获取插件,因为抛出的错误是找不到插件。

最新更新