Reputation: 364
my app isn't building again, don't know what I did wrong. The error message is listed below
C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.0+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:9: error: package androidx.annotation does not exist
import androidx.annotation.NonNull;
^
C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.0+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:10: error: package androidx.annotation does not exist
import androidx.annotation.Nullable;
^
C:\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_auth-0.8.0+1\android\src\main\java\io\flutter\plugins\firebaseauth\FirebaseAuthPlugin.java:638: error: cannot find symbol
Upvotes: 8
Views: 2639
Reputation: 29468
I've added this in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
It helped me
Upvotes: 2
Reputation: 2260
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.
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
Upvotes: 6
Reputation: 5605
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
.
Upvotes: 3