错误完成:Gradle任务assembleDebug失败,退出代码为1 [英] Finished with error: Gradle task assembleDebug failed with exit code 1

查看:2101
本文介绍了错误完成:Gradle任务assembleDebug失败,退出代码为1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I just tried to add the firebase to the project

推荐答案

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

The primary problem looks to be that you are using version 0.9.0 of the cloud_firestore plugin which has been migrated to AndroidX, but your project has not been migrated. So, it would appear the two options are to either use the previous version of the cloud_firestore plugin or migrate your project to AndroidX.

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

To migrate your project to AndroidX, follow the link I mention in my comment above (Firebase auth plugin crash IOS and android #27422) and under the Android section of my initial response (posted under username app-o-matix), follow Steps 1-3. The remaining steps and follow up post may be of help in avoiding additional problems.

以下是链接页面中的步骤1-3(我使用IntelliJ Idea CE,然后选择了Swift和Kotlin创建Flutter项目):

Here are Steps 1-3 from the linked page (I use IntelliJ Idea CE and select Swift and Kotlin in creating my Flutter projects):

1)在Android Studio中打开Flutter项目的Android部分。确保您使用的是Android Studio 3.3。 (我完全关闭了IntelliJ Idea,打开Android Studio,单击 File> Open ,然后导航到〜/ IdeaProjects / [my_project] / android 我的Flutter项目中的文件夹。打开Android项目,然后开始同步它的Android Studio时,出现一条消息/弹出窗口,询问是否可以更新Gradle插件,所以我让它了。它已升级到版本 3.3 .0 。)

1) Open the Android portion of your Flutter project in Android Studio. Make sure you are using Android Studio 3.3. (I closed IntelliJ Idea altogether, opened Android Studio, clicked on File > Open, and navigated to the ~/IdeaProjects/[my_project]/android folder in my Flutter project. Upon opening the Android project followed by Android Studio starting to sync it, a message/pop-up appeared asking if it could update the Gradle plugin, so I let it. It was upgraded to version 3.3.0.)

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

2) Add the following 2 lines to the bottom of the [my_project]/android/gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true




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

Note: I'm not sure if android.enableJetifier=true could have been, or should have been, set to false. Perhaps someone else can clarify under which conditions it should be true vs false. 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 to true 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。

3) In the Android Studio main menus, select Refactor > Migrate to Androidx..., saving a backup of your project to a .zip file. Follow this with File > Save All and then quit Android Studio.

作为迁移后的一项额外措施,在IntelliJ Idea中,我运行工具> Flutter> Flutter Clean 文件>全部保存文件>使缓存无效并重新启动,在这里我选择使缓存无效并重新启动,然后在重新启动工具> Flutter> Flutter软件包获取

As an extra measure after the migration, in IntelliJ Idea I run Tools > Flutter > Flutter Clean, File > Save All, File > Invalidate Caches and Restart where I choose to both invalidate caches and restart, then after the restart Tools > Flutter > Flutter Packages Get.

这篇关于错误完成:Gradle任务assembleDebug失败,退出代码为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆