android 评估项目“:app”时出现问题- Firebase与Flutter集成

n9vozmp4  于 2023-05-12  发布在  Android
关注(0)|答案(1)|浏览(171)

我正在尝试将Firebase集成到我现有的Flutter应用程序中。在集成之前,我已经将我的项目从Android Studio迁移到了AndroidX。我已经完成了官方指南中提到的将Firebase集成到Flutter中的步骤。当我运行应用程序时,它会给我错误:

  • 运行Gradle时出错:ProcessException:进程“E:\My Projects\MyProject\android\gradlew.bat”异常退出:

失败:生成失败,出现异常。

  • 其中:构建文件'E:\My Projects\MyProject\android\app\build.gradle'行:24
  • 出了什么问题:评估项目“:app”时出现问题。

ASCII码

  • Try:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整的见解。
  • https://help.gradle.org获取更多帮助

BUILD在8 s命令中失败:E:\My Projects\MyProject\android\gradlew.bat app:properties
请在android/文件夹中查看Gradle项目设置。
我搜索了这个错误,找到了一些指示从com.google.gms:google-services:4.3.2切换到com.google.gms:google-services:4.2.0的答案。这样做,得到了这个错误:
registerResGeneratingTask已弃用,use registerGeneratedResFolders(FileCollection)registerResGeneratingTask已弃用,use registerGeneratedResFolders(FileCollection)registerResGeneratingTask已弃用,use registerGeneratedResFolders(FileCollection)Gradle任务装配调试失败,退出代码为% 1
搜索了一下,发现com.google.gms:google-services:4.3.0修复了这个问题。所以我在build.gradle中使用了它,这是我得到的:

  • 运行Gradle时出错:ProcessException:进程“E:\My Projects\MyProject\android\gradlew.bat”异常退出:

失败:生成失败,出现异常。

  • 其中:构建文件'E:\My Projects\MyProject\android\app\build.gradle'行:24
  • 出了什么问题:评估项目“:app”时出现问题。

ASCII码

  • Try:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整的见解。
  • https://help.gradle.org获取更多帮助

BUILD在5s命令中失败:E:\My Projects\MyProject\android\gradlew.bat app:properties
请在android/文件夹中查看Gradle项目设置。
似乎没有什么对我有用。请在下面找到gradle文件的内容。

android/gradle.properties:

android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M

android/build.gradle:

buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

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
}

android/app/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: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.buy_io"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    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 '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}

apply plugin: 'com.google.gms.google-services'

pubspec.yaml:

name: my_app
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.2.2 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_money_formatter: ^0.8.3
  font_awesome_flutter: ^8.5.0
  firebase_core: ^0.4.0+9
  firebase_auth: ^0.14.0+5
  cloud_firestore: ^0.12.9+5

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  uses-material-design: true
  assets:
    - images/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Muli
      fonts:
        - asset: fonts/Muli-ExtraLight.ttf
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages
4ioopgfo

4ioopgfo1#

这里最好的做法是尝试删除您已经设置的Firebase SDK,并查看Flutter项目是否构建。然后尝试使用flutterfire configure设置Firebase。您可以从文档中关注this guide以了解更多详细信息。

相关问题