8
votes

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
4
"Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." In this case I'd expect that to be/include your pubspec.yaml file.Frank van Puffelen

4 Answers

3
votes

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.

6
votes

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

enter image description here

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
2
votes

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.

2
votes

I've added this in gradle.properties

android.useAndroidX=true
android.enableJetifier=true

It helped me