[英]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: 我遵循了以下步骤:
dependencies:
firebase_auth: ^0.8.4+2
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.