Launching lib\main.dart on HTC One M9PLUS in debug mode... Initializing gradle... Resolving dependencies... Gradle task 'assembleDebug'... registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.9.0\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:9: error: cannot find symbol import androidx.annotation.NonNull;
^ symbol: class NonNull location: package androidx.annotation C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.9.0\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:10: error: cannot find symbol import androidx.annotation.Nullable;
^ symbol: class Nullable location: package androidx.annotation C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.9.0\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:253: error: cannot find symbol
public void onFailure(@NonNull Exception e) {
^ symbol: class NonNull C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.9.0\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:274: error: cannot find symbol
public Void apply(@NonNull Transaction transaction)
^ symbol: class NonNull C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.9.0\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:272: error: cannot find symbol
@Nullable
^ symbol: class Nullable C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.9.0\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:503: error: cannot find symbol
public void onFailure(@NonNull Exception e) {
^ symbol: class NonNull C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.9.0\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:558: error: cannot find symbol
public void onFailure(@NonNull Exception e) {
^ symbol: class NonNull 7 errors
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 26s Finished with error: Gradle task assembleDebug failed with exit code 1
我刚刚尝试将 firebase 添加到项目中
最佳答案
主要问题似乎是您使用的是已迁移到 AndroidX 的 0.9.0 版 cloud_firestore
插件,但您的项目尚未迁移。因此,这两个选项似乎是使用以前版本的 cloud_firestore
插件或将您的项目迁移到 AndroidX。
要将您的项目迁移到 AndroidX,请点击我在上面的评论中提到的链接 (Firebase auth plugin crash IOS and android #27422) 以及我最初回复的 Android 部分(发布在用户名 app-o-matix 下) ,按照步骤 1-3。其余步骤和后续帖子可能有助于避免其他问题。
以下是链接页面中的步骤 1-3(我使用 IntelliJ Idea CE 并选择 Swift 和 Kotlin 来创建我的 Flutter 项目):
1) 在 Android Studio 中打开 Flutter 项目的 Android 部分。确保您使用的是 Android Studio 3.3。 (我完全关闭了 IntelliJ Idea,打开 Android Studio,点击 File > Open,然后导航到 Flutter 项目中的 ~/IdeaProjects/[my_project]/android
文件夹。打开 Android 项目后,Android Studio 开始同步它,出现一条消息/弹出窗口,询问它是否可以更新 Gradle 插件,所以我让它。它已升级到版本 3.3.0 .)
2) 在[my_project]/android/gradle.properties
文件的底部添加以下2行:
android.useAndroidX=true
android.enableJetifier=true
Note: I'm not sure if
android.enableJetifier=true
could have been, or should have been, set tofalse
. Perhaps someone else can clarify under which conditions it should betrue
vsfalse
. I believe it has something to do with whether or not the project has additional libraries that haven't yet been migrated to AndroidX, but, if my belief is correct, I don't know if when this setting is set totrue
it means Android Studio will migrate these libraries to AndroidX or that it will make code adjustments to account for the fact that the libraries aren't yet AndroidX compatible. Or maybe I'm totally wrong and it is something else altogether.
3) 在 Android Studio 主菜单中,选择重构 > 迁移到 Androidx...,将项目的备份保存到 .zip 文件。使用 File > Save All 执行此操作,然后退出 Android Studio。
作为迁移后的额外措施,在 IntelliJ Idea 中我运行 Tools > Flutter > Flutter Clean、File > Save All、File > Invalidate Caches 和重新启动 我选择使缓存无效并重新启动,然后在重新启动后 Tools > Flutter > Flutter Packages Get。
关于firebase - 完成错误 : Gradle task assembleDebug failed with exit code 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54510465/