当前位置: 首页 > 知识库问答 >
问题:

我试图连接我的flutter应用程序与Firebase和我赶上了这个错误

郑宇
2023-03-14

我试图将我的Flitter应用程序与firebase连接,但我发现了这个错误。提前感谢:)

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

  • 错误:配置根项目“android”时出现问题

无法解析配置: classpath的所有工件。无法解决com.google.gms: google-service: 4.3.8.所需:项目:

>

  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。使用--scan运行以获得完整的洞察力。

    得到更多的帮助https://help.gradle.org

    生成在28s中失败异常:Gradle任务assembleDebug失败,退出代码为1

    我的应用程序\构建。格拉德尔:

    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 plugin: 'com.google.gms.google-services'
    apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
    
    android {
        compileSdkVersion 30
    
        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }
    
        defaultConfig {
            // TODO: Specify your own unique Application ID 
        (https://developer.android.com/studio/build/application-id.html).
            applicationId "com.example.untitled2"
            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 '../..'
    }
    
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation platform('com.google.firebase:firebase-bom:28.1.0')
    }
    

    我的android\build。格拉德尔:

    buildscript {
        repositories {
            google()
            mavenCentral()
            jcenter()
    
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.0'
            classpath 'com.google.gms:google-services:4.3.8'
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            jcenter()
        }
    }
    
    rootProject.buildDir = '../build'
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    颤动医生-v:

    [√] Flutter (Channel stable, 2.0.5, on Microsoft Windows [Version 10.0.19042.1023], locale en-IN)
        • Flutter version 2.0.5 at C:\flutter
        • Framework revision adc687823a (8 weeks ago), 2021-04-16 09:40:20 -0700
        • Engine revision b09f014e96
        • Dart version 2.12.3
    
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        • Android SDK at C:\Users\Geo Swift Sam\AppData\Local\Android\sdk
        • Platform android-30, build-tools 30.0.3
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
        X Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
    
    [√] Chrome - develop for the web
        • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    
    [√] Android Studio (version 4.1.0)
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin can be installed from:
           https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
           https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    
    [√] Connected device (3 available)
        • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
        • Chrome (web)                       • chrome        • web-javascript • Google Chrome 91.0.4472.101
        • Edge (web)                         • edge          • web-javascript • Microsoft Edge 90.0.818.66
    
    ! Doctor found issues in 1 category.
    
  • 共有2个答案

    白博赡
    2023-03-14

    在您的android/build中。gradle将google服务版本从4.3更改。84.3。3如文件中所述

    classpath 'com.google.gms:google-services:4.3.3'
    

    试一试,让我知道。

    文件参考:https://firebase.flutter.dev/docs/installation/android

    李鸿
    2023-03-14

    这听起来可能是一个愚蠢的答案,但这似乎是一个互联网连接问题。在我的移动网络上进行gradle同步时,我也遇到过类似的问题,尽管它在局域网中运行良好。

     类似资料: