我的 build.gradle 有问题(Flutter)

问题描述 投票:0回答:1

我的应用程序不再运行,在 android root build.gradle、类路径和我的路径“com.google.gms.google-services:4.3.2”中指出错误。具体来说:

出了什么问题: 配置根项目“android”时出现问题。 无法解析配置“:classpath”的所有文件。 找不到 com.google.gms.google-services:4.3.2:。 要求者: 项目:

我尝试将 Firebase 与我的 Flutter 应用程序集成,但是当我去 build.gradle 添加类路径时,没有“依赖项”字段,所以我自己编写了它,问题就开始了

这是我的android uild.gradle代码

buildscript {
    repositories {
        google()

    }
    dependencies {
        classpath 'com.google.gms.google-services:4.4.2'
    }
}
allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

这是我的应用程序 uild.gradle 代码

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
    id 'com.google.gms.google-services'
}

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

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.example.projetoelise"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.projetoelise"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        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 = "../.."
}
android flutter firebase gradle
1个回答
0
投票

您无需手动添加依赖项,这些过程现在已自动化。

  1. 创建一个新的 Flutter 项目
  2. 按照下面的官方文档进行操作

https://firebase.google.com/docs/flutter/setup?platform=android

© www.soinside.com 2019 - 2024. All rights reserved.