How to stop firebase error in flutter app
Solution
Add: implementation 'androidx.annotation:annotation:1.0.1'
to the build.gradle of firebase_auth library. I used Android Studio to see the flutter android app structure.
From Android Studio
Sample Code:
build.graddle(firebase_auth library):android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
dependencies {
api 'com.google.firebase:firebase-auth:16.0.1'
implementation 'androidx.annotation:annotation:1.0.1'
}
}
pubspec.yaml(dependencies)
flutter:
sdk: flutter
rxdart: ^0.20.0
firebase_core: ^0.3.0
firebase_analytics: ^2.0.0
firebase_auth: ^0.8.0+1
google_sign_in: ^4.0.0
There seems to be a bug in the latest version of some of the Google plugins where they migrated to AndroidX. I've made a pull request with a fix but it likely won't be reviewed before Monday.
A workaround meanwhile is to downgrade to a working version in your pubspec. E.g. I had firebase_storage: ^1.1.0
, and after looking at the changelog to identify a previous version, I changed that line to firebase_storage: 1.0.4
.
You need to migrate your project to AndroidX. You can refer this link to migrate your project. And also see change logs for firebase_auth here.