简体   繁体   中英

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. But I'm having trouble compiling the project when I enter dependency on firebase_auth.

I followed the steps:

  1. I inserted the latest version of firebase_auth in pubspec.yaml
dependencies:
  firebase_auth: ^0.8.4+2
  1. Clicked on Packages get. Successful
  2. Run '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.

Is it really an Android compatibility issue?

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. The newest version of firebase_auth relies on AndroidX and you can't have both legacy support libraries alongside AndroidX now.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM