繁体   English   中英

我试图将我的 flutter 应用程序与 firebase 连接起来,但我遇到了这个错误

[英]I tried to connect my flutter app with firebase and I catch up with this error

我试图将我的 flutter 应用程序与 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 选项运行以获得更多日志 output。 运行 --scan 以获得完整的见解。

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

BUILD FAILED in 28s Exception: Gradle task assembleDebug failed with exit code 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
}

flutter 医生-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.

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

如文档中所述,在您的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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM