简体   繁体   English

Flutter 应用程序未使用 cloud_firestore 插件编译

[英]Flutter app is not compiled with cloud_firestore plugin

I already added google-service.json under android/app .我已经在android/app下添加了google-service.json But I've got error message when try build app.但是我在尝试构建应用程序时收到错误消息。

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cloud_firestore:processDebugGoogleServices'.
   > Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Finished with error: Gradle task assembleDebug failed with exit code 1

I tried flutter clean -> flutter packages get but it can't solve my problem.我试过flutter clean -> flutter packages get但它不能解决我的问题。

pubspec.yaml pubspec.yaml

version: 1.0.0+1

environment:
    sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
    flutter:
        sdk: flutter

    cupertino_icons: ^0.1.2
    http: ^0.11.3+17
    json_annotation: ^0.2.3
    cloud_firestore: ^0.8.0

app/build.gradle应用程序/build.gradle

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:multidex:1.0.3'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

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

I didn't add implementation 'com.google.firebase:firebase-core:16.0.3' and implementation 'com.google.firebase:firebase-database:16.0.2' because, I follow the codelab guide.( https://codelabs.developers.google.com/codelabs/flutter-firebase/#5 )我没有添加implementation 'com.google.firebase:firebase-core:16.0.3'implementation 'com.google.firebase:firebase-database:16.0.2'因为,我遵循了代码实验室指南。( https:// /codelabs.developers.google.com/codelabs/flutter-firebase/#5 )

This line specifies version 3.2.1 of the plugin (do not use version 3.3.0 or 3.3.1 at this point).此行指定插件的版本3.2.1 (此时不要使用版本 3.3.0 或 3.3.1)。 For more information see the Add the SDK section of the Add Firebase to Your Android Project documentation (but don't follow those instructions as they are different from the Flutter instructions) .有关更多信息,请参阅将 Firebase 添加到您的 Android 项目文档的添加 SDK 部分(但不要遵循这些说明,因为它们与 Flutter 说明不同)

build.gradle (project) build.gradle(项目)

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

Update更新

I also tried with update gradle version to 4.6.我还尝试将 gradle 版本更新到 4.6。 File -> Project Structure -> Project文件->项目结构->项目

dependencies {
  classpath 'com.android.tools.build:gradle:3.2.0'
  classpath 'com.google.gms:google-services:4.1.0'
}

But still error occurs.但仍然发生错误。

If I tried gradle sync,如果我尝试 gradle 同步,

Unable to resolve dependency for ':app@dynamicProfile/compileClasspath': Could not resolve project :cloud_firestore.

Unable to resolve dependency for ':app@dynamicProfile/compileClasspath': Could not resolve project :firebase_core.

And tried build flutter binary,并尝试构建颤振二进制文件,

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cloud_firestore:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
  /Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/nullnull/debug/google-services.json
  /Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/debug/nullnull/google-services.json
  /Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/nullnull/google-services.json
  /Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/debug/google-services.json
  /Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/src/nullnullDebug/google-services.json
  /Users/kenny/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.0/android/google-services.json

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
Finished with error: Gradle task assembleDebug failed with exit code 1

google-service.json google-service.json

{
  "project_info": {
    "project_number": "1234566",
    "firebase_url": "https://XXXXXX.firebaseio.com",
    "project_id": "XXXXXX",
    "storage_bucket": "XXXXXX.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:123456:android:1234567890",
        "android_client_info": {
          "package_name": "com.package.name"
        }
      },
      "oauth_client": [
        {
          "client_id": "client_id.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "client_key"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 2
        }
      }
    }
  ],
  "configuration_version": "1"
}

Self solution自我解决

Use 0.7.4 version instead of 0.8.0 for cloud_firestore .对于cloud_firestore使用0.7.4版本而不是0.8.0

Change gradle dependencies更改 gradle 依赖项

dependencies {
  classpath 'com.android.tools.build:gradle:3.1.2'
  ...
}

Use multiDex使用 multiDex

This works for me.这对我有用。

Flutterfire has recently rolled out Dart-only initialization which should help prevent setup issues similar to this from happening. Flutterfire 最近推出了 Dart-only 初始化,这应该有助于防止发生类似的设置问题。 Follow this guide laid out on their docs to migrate from manual platform-specific setups to Dart-only initialization.按照他们的文档中列出的本指南从手动平台特定设置迁移到仅 Dart 初始化。

暂无
暂无

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

相关问题 Flutter cloud_firestore package 使应用程序崩溃 - Flutter cloud_firestore package makes app crash 获取 cloud_firestore:0.9.0 依赖项会破坏 Flutter 应用程序 - getting cloud_firestore: 0.9.0 dependency breaks flutter app 添加“cloud_firestore”时出现颤振错误 - Flutter error when adding "cloud_firestore" 由于 CloudFirestorePlugin.java 使用了未经检查或不安全的操作,因此无法构建 flutter 插件 cloud_firestore [flutter build apk] - flutter plugin cloud_firestore could not be built because CloudFirestorePlugin.java uses unchecked or unsafe operations [flutter build apk] 如何修复 flutter cloud_firestore 依赖项? - How do I fix flutter cloud_firestore dependencies? Flutter:任务&#39;执行失败&#39;:cloud_firestore:compileDebugJavaWithJavac&#39; - Flutter: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac' Flutter - 任务“:cloud_firestore:compileDebugJavaWithJavac”执行失败 - Flutter - Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac' Flutter-Firebase 构建失败':cloud_firestore:compileDebugJavaWithJavac' - Flutter-Firebase Build Failed ':cloud_firestore:compileDebugJavaWithJavac' Flutter Firestore [cloud_firestore/not-found] 找不到一些请求的文件 - Flutter Firestore [cloud_firestore/not-found] Some requested document was not found 我无法在 Flutter 中同时添加 cloud_firestore 和 firebase_auth - I cannot add cloud_firestore and firebase_auth together in Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM