【问题标题】:Fail to compile flutter app with firebase on the last version of both无法在两者的最后一个版本上使用 firebase 编译颤振应用程序
【发布时间】:2019-08-31 09:17:49
【问题描述】:

我从颤振开始。 我编译了 Hello World 项目,它工作正常。 但是当我输入对 firebase_auth 的依赖时,我无法编译项目。

我按照以下步骤操作:

  1. 我在 pubspec.yaml 中插入了最新版本的 firebase_auth
dependencies:
  firebase_auth: ^0.8.4+2
  1. 单击包获取。成功
  2. 运行“main.dart”。错误!
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
/usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.4+2/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:9: error: cannot find symbol
import androidx.annotation.NonNull;
                          ^
  symbol:   class NonNull
  location: package androidx.annotation
/usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.8.4+2/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:10: error: cannot find symbol
import androidx.annotation.Nullable;

...

BUILD FAILED in 16s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************

我见过的所有将 firebase_auth 与 Flutter 集成的教程都有效,但是在以前的版本中。

真的是安卓兼容性问题吗?

我搜索了几个小时关于错误但没有找到解决方案。

【问题讨论】:

  • 尝试将项目android项目打开到Android Studio并修复Gradle问题。它可能会有所帮助

标签: firebase flutter firebase-authentication


【解决方案1】:

尝试按照本教程,在 Android Studio 中打开您的 Android 应用,然后将 Gradle 中的库转换为 AndroidX。最新版本的 firebase_auth 依赖于 AndroidX,您现在不能同时拥有旧版支持库和 AndroidX。

我遇到了同样的问题,并且能够通过遵循此文档来解决它。当您打开 Flutter Android 项目时,在 Android Studio 的一个顶部菜单下有一个选项,它只会显示“转换为 AndroidX”。

https://developer.android.com/jetpack/androidx/migrate

【讨论】:

  • 对不起,糟糕的指示,但很高兴你能够让它工作!
猜你喜欢
  • 2019-12-12
  • 1970-01-01
  • 2019-06-03
  • 1970-01-01
  • 1970-01-01
  • 2018-12-16
  • 2021-10-23
  • 2020-04-20
  • 2020-07-22
相关资源
最近更新 更多