【问题标题】:I tried to connect my flutter app with firebase and I catch up with this error我试图将我的颤振应用程序与 firebase 连接起来,但我发现了这个错误
【发布时间】:2021-08-28 12:30:59
【问题描述】:

我试图将我的颤振应用程序与 firebase 连接起来,但我发现了这个错误。在此先感谢:)

FAILURE:构建失败并出现异常。

  • 出了什么问题: 配置根项目“android”时出现问题。

无法解析配置“:classpath”的所有工件。 无法解析 com.google.gms:google-services:4.3.8。 要求: 项目 : > 无法解析 com.google.gms:google-services:4.3.8。 > 无法获取资源“https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.8/google-services-4.3.8.pom”。 > 无法获取“https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.8/google-services-4.3.8.pom”。 > 连接到 127.0.0.1:8080 [/127.0.0.1] 失败:连接被拒绝:连接 > 无法解析 com.google.gms:google-services:4.3.8。 > 无法获取资源“https://jcenter.bintray.com/com/google/gms/google-services/4.3.8/google-services-4.3.8.pom”。 > 无法获取“https://jcenter.bintray.com/com/google/gms/google-services/4.3.8/google-services-4.3.8.pom”。 > 连接到 127.0.0.1:8080 [/127.0.0.1] 失败:连接被拒绝:连接

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

  • 通过https://help.gradle.org获得更多帮助

在 28 秒内构建失败 异常:Gradle 任务 assembleDebug 失败,退出代码为 1

我的应用\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 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.gradle:

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.

【问题讨论】:

  • 能否提供命令flutter doctor -v的输出?
  • @Chrissi 我现在用 flutter doctor -v 命令更新了我的问题。在此先感谢:)

标签: android flutter android-studio gradle google-play-services


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    按照文档中的说明,在您的 android/build.gradle 中将 google-services 版本从 4.3.8 更改为 4.3.3

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

    试一试,然后告诉我。

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

    【讨论】:

    • 我尝试将 google-services 版本从 4.3.8 更改为 4.3.3,但它不起作用
    猜你喜欢
    • 2020-02-03
    • 2021-04-19
    • 1970-01-01
    • 2020-06-05
    • 2021-08-20
    • 2021-06-29
    • 2020-08-12
    • 2022-01-07
    • 1970-01-01
    相关资源
    最近更新 更多