简体   繁体   English

无法在两个版本的最新版本上使用Firebase编译Flutter应用

[英]Fail to compile flutter app with firebase on the last version of both

I'm starting with flutter. 我从扑打开始。 I compiled the Hello World project and it worked. 我编译了Hello World项目,它成功了。 But I'm having trouble compiling the project when I enter dependency on firebase_auth. 但是当我输入对firebase_auth的依赖项时,我在编译项目时遇到了麻烦。

I followed the steps: 我遵循了以下步骤:

  1. I inserted the latest version of firebase_auth in pubspec.yaml 我在pubspec.yaml中插入了最新版本的firebase_auth
dependencies:
  firebase_auth: ^0.8.4+2
  1. Clicked on Packages get. 单击包获取。 Successful 成功的
  2. Run 'main.dart'. 运行“ main.dart”。 ERROR! 错误!
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.
*******************************************************************************************

All the tutorials I've seen integrating firebase_auth with flutter worked, however in previous versions. 我见过的所有将firebase_auth与flutter集成的教程都可以使用,但是在以前的版本中。

Is it really an Android compatibility issue? 确实是Android兼容性问题吗?

I searched for hours about the error but found no solution. 我搜索了几个小时的错误,但没有找到解决方案。

Try following this tutorial, open your Android app in Android Studio and convert your libraries in Gradle to AndroidX. 尝试按照本教程操作,在Android Studio中打开Android应用,然后将Gradle中的库转换为AndroidX。 The newest version of firebase_auth relies on AndroidX and you can't have both legacy support libraries alongside AndroidX now. firebase_auth的最新版本依赖于AndroidX,并且您不能同时拥有两个旧版支持库和AndroidX。

I had this same problem and was able to solve it by following this document. 我遇到了同样的问题,并且可以通过遵循本文档来解决。 There is an option in Android Studio under one of the top menus that simply says "Convert to AndroidX" when you've opened your Flutter Android project. 当您打开Flutter Android项目时,Android Studio的一个顶级菜单下有一个选项只是显示“转换为AndroidX”。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Flutter + Firebase 无法打开 iOS 应用程序 - Fail to open iOS app using Flutter + Firebase 在 Flutter 网页和移动应用中使用 Firebase - Use Firebase in both Flutter web AND mobile app 嵌入式 Flutter 应用程序和本机 Android 中的 Firebase 身份验证 - Firebase Authentication in both Embedded Flutter app and Native Android 如何同时为移动和桌面制作 Flutter Firebase 应用程序 - How to do a Flutter Firebase app for both Mobile and Desktop at the same time 使用颤振将图像上传到 Firebase 失败 - Uploading images to Firebase with flutter fail 如何知道在 Flutter 应用程序中使用哪个版本的 Google Firebase 插件? - How to know which version of Google Firebase plugin to use in Flutter app? 安装新应用程序版本后 Firebase 数据库不起作用。 扑 - Firebase database not working after a new app version is installed. Flutter Firebase 仅托管以前版本的 Flutter Web 应用程序 - Firebase only hosts previous version of Flutter web app 如何使用 Firebase 后端处理 Flutter 中的用户角色? 客户端和管理应用程序或两者在一个应用程序中? - How to handle with user role in Flutter with Firebase backend? Client & admin app or both in one app? Android App + Firebase初始化失败 - Android App + Firebase initializations fail
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM