无法找到构建 Flutter 项目时显示的 firebase_core FlutterFire 插件错误

问题描述

我在构建 Flutter 项目时遇到以下错误: *评估项目“:firebase_ml_vision”时出现问题。

找不到 firebase_core FlutterFire 插件,您是否将其添加为 pubspec 的依赖项*

这是否意味着我必须安装一些额外的库?我只想在我的项目中使用 ML Vision。感谢您的帮助。

我的pubspec.yaml 文件

dependencies:
  Flutter:
    sdk: Flutter
  get: ^3.24.0

  firebase_ml_vision: ^0.11.0
  image_picker: ^0.6.3+4
  image_cropper: 1.0.2

build.gradle(应用):

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def FlutterRoot = localProperties.getProperty('Flutter.sdk')
if (FlutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with Flutter.sdk in the local.properties file.")
}

def FlutterVersionCode = localProperties.getProperty('Flutter.versionCode')
if (FlutterVersionCode == null) {
    FlutterVersionCode = '1'
}

def FlutterVersionName = localProperties.getProperty('Flutter.versionName')
if (FlutterVersionName == null) {
    FlutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply from: "$FlutterRoot/packages/Flutter_tools/gradle/Flutter.gradle"

android {
    compileSdkVersion 30

    defaultConfig {
        // Todo: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.grobonet"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode FlutterVersionCode.toInteger()
        versionName FlutterVersionName
    }

    buildTypes {
        release {
            // Todo: Add your own signing config for the release build.
            // Signing with the debug keys for Now,so `Flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

Flutter {
    source '../..'
}

build.gradle(项目)

buildscript {
    repositories {
        google()
        jcenter()
    }

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

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

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

解决方法

firebase_core 添加到您的项目中。