一尘不染

错误完成:Gradle任务assembleDebug失败,退出代码为1

flutter

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添加到项目中


阅读 638

收藏
2020-08-13

共1个答案

一尘不染

主要问题似乎是您使用的cloud_firestore插件版本0.9.0
已迁移到AndroidX,但您的项目尚未迁移。因此,看来这两个选项是使用该cloud_firestore插件的先前版本或将您的项目迁移到AndroidX。

要将您的项目迁移到AndroidX,请按照我在上面的评论中提到的链接(Firebase
auth插件崩溃IOS和android#27422
)以及我的初始响应的Android部分(发布在用户名
app-o-matix下 )下,按照步骤1进行操作。 -3。其余步骤和后续帖子可能有助于避免其他问题。

这是链接页面上的步骤1-3(我使用IntelliJ Idea CE,并在创建Flutter项目时选择了Swift和Kotlin):

1)在Android Studio中打开Flutter项目的Android部分。确保您使用的是Android Studio
3.3。(我完全关闭了IntelliJ Idea,打开了Android Studio,单击“ _文件”

“打开”,然后导航到~/IdeaProjects/[my_project]/androidFlutter项目中的文件夹。打开Android项目后,Android
Studio开始对其进行同步,出现一条消息/弹出窗口,询问是否它可以更新Gradle插件,所以我允许它。它已升级到版本 _3.3.0
。)

2)在文件 底部 添加以下两行[my_project]/android/gradle.properties

android.useAndroidX=true
android.enableJetifier=true

注意
:我不确定是否android.enableJetifier=true可以将设置为false。也许别人可以阐明它应该是在什么条件下trueVS
false。我认为这与项目是否还有尚未迁移到AndroidX的其他库有关,但是,如果我的想法是正确的,我不知道何时将此设置设置为true意味着Android
Studio会将这些库迁移到AndroidX或对其进行代码调整,以说明这些库尚不兼容AndroidX。也许我完全错了,这完全是另外一回事。

3)在Android Studio主菜单中,选择“ 重构” >“迁移到Androidx …”将项目的备份保存到.zip文件中
。依次执行“ 文件” >“全部保存”,然后退出Android Studio。

作为迁移后的一项额外措施,在IntelliJ Idea中,我运行“ 工具” >“ Flutter”>“ Flutter Clean”,“ _文件”

“保存所有”,“ _File” >“ Invalidate Caches and Restart”,在这里我选择使缓存无效并重新启动,然后在重启后“
Tools” >“ Flutter”>“ Flutter”包Get

2020-08-13