【问题标题】:flutter plugin cloud_firestore could not be built because CloudFirestorePlugin.java uses unchecked or unsafe operations [flutter build apk]无法构建flutter插件cloud_firestore,因为CloudFirestorePlugin.java使用未经检查或不安全的操作[flutter build apk]
【发布时间】:2020-06-29 22:49:47
【问题描述】:

我正在构建一个使用多个 firebase 依赖项的 Flutter 应用程序,但 cloud_firestore 依赖项在调试和构建应用程序时总是返回错误。

这是构建日志

You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                                
Note: /flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.13.4+2/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.                                                                 
Note: Some input files use unchecked or unsafe operations.                                                         
Note: Recompile with -Xlint:unchecked for details.                                                                 
Calling mockable JAR artifact transform to create file: /Users/user/.gradle/caches/transforms-2/files-2.1/323813f5a095cba9aa563dadb749a1cb/android.jar with input /Users/user/Library/Android/sdk/platforms/android-28/android.jar
Calling mockable JAR artifact transform to create file: /Users/user/.gradle/caches/transforms-2/files-2.1/ff23381473fa92d0c047c8663bfbe6a6/android.jar with input /Users/user/Library/Android/sdk/platforms/android-27/android.jar
Calling mockable JAR artifact transform to create file: /Users/user/.gradle/caches/transforms-2/files-2.1/43c9f60e6803ddaaef16828845e40f49/android.jar with input /Users/user/Library/Android/sdk/platforms/android-29/android.jar
Removed unused resources: Binary resource data reduced from 329KB to 261KB: Removed 20%                            

FAILURE: Build failed with an exception.                                                                           

* What went wrong:                                                                                                 
Execution failed for task ':google_sign_in:verifyReleaseResources'.                                                
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade                  
   > Android resource linking failed                                                                               
     /Users/user/.gradle/caches/transforms-2/files-2.1/9dacf9516413cf5e5b34c6b4508340e4/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

     /Users/user/.gradle/caches/transforms-2/files-2.1/9dacf9516413cf5e5b34c6b4508340e4/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.


* 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 7m 10s                                                                                             
Running Gradle task 'assembleRelease'...                                                                           
Running Gradle task 'assembleRelease'... Done                     441.0s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
✏️  Creating 'android/settings_aar.gradle'...                       35ms
✓ 'android/settings_aar.gradle' created successfully.
Building plugin cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.

使用的 pubspec.yaml firebase 依赖项:

firebase_core: ^0.4.4+3
cloud_firestore: ^0.13.4+2
firebase_auth: ^0.15.5+2 

任何有工作的 firebase 依赖项的人请在下面分享它们。

【问题讨论】:

  • 似乎这是一个已知的行为:issuetracker.google.com/issues/110797725我如何重现这个?
  • @Mario 我不知道如何重现它,我只是使用了遇到它时的最新版本的 firebase 依赖项

标签: android firebase flutter firebase-realtime-database google-cloud-firestore


【解决方案1】:

这似乎是一个暂时性问题,并且某些工具堆栈未正确同步。

我的建议是重新加载依赖项和所涉及的工具,因为在Issue Tracker 中,Android Studio 或 Gradle 之类的东西是通过以下方式恢复的:

  1. 删除文件夹:/.gradle 和 /.gradle
  2. 尝试使用本地 gradle 分发进行设置。

希望这很有用!

【讨论】:

    【解决方案2】:

    要解决这个问题,请尝试两件事:

    1. 在项目/android/app/build.gradle

      defaultConfig {
        ...
         multiDexEnabled true
      }
      
    2. 在终端运行flutter pub upgrade

    【讨论】:

    • MultiDexEnabled 设置为true 然后运行flutter clean 然后flutter pub upgrade 但我得到了同样的错误
    猜你喜欢
    • 1970-01-01
    • 2019-11-18
    • 2020-09-10
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多