Ive spent days trying to debug my app using Firebase. Previously it was working all fine not until last week when i updated a whole lot of things; android studio, flutter, plugins etc. Upon compiling this is always my result;
import android.support.annotation.NonNull;
^
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:538: error: cannot find symbol
public void onComplete(@NonNull Task<AuthResult> task) {
^
symbol: class NonNull
location: class FirebaseAuthPlugin.SignInCompleteListener
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:558: error: cannot find symbol
public void onComplete(@NonNull Task<Void> task) {
^
symbol: class NonNull
location: class FirebaseAuthPlugin.TaskVoidCompleteListener
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:576: error: cannot find symbol
public void onComplete(@NonNull Task<ProviderQueryResult> task) {
^
symbol: class NonNull
location: class FirebaseAuthPlugin.ProvidersCompleteListener
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:175: error: cannot find symbol
public void onComplete(@NonNull Task<AuthResult> task) {
^
symbol: class NonNull
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:270: error: cannot find symbol
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
^
symbol: class NonNull
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:435: error: cannot find symbol
public void onComplete(@NonNull Task<GetTokenResult> task) {
^
symbol: class NonNull
/home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java:487: error: cannot find symbol
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
^
symbol: class NonNull
Note: /home/baw/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.2+1/android/src/main/java/io/flutter/plugins/firebaseauth/FirebaseAuthPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_auth:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 48s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin cloud_firestore...
Running Gradle task 'assembleAarRelease'...
Exception: The plugin cloud_firestore could not be built due to the issue above.
Ive tried different fixes regarding androidX but my project is already migrated and has always been so none seems to work.
Flutter doctor output is just fine
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Android Studio
[✓] Connected device (1 available)
• No issues found!```
SOLUTION FOUND!!
This was being caused by AndroidX issues indeed but migrating helped in no way. So steps i used to solve it are;
Open the android folder for Editing with Android Studio. 2.Run Gradle sync. 3.Run the app. (This will fail obviously!, but take you to the file where the Android Support Library import was used.)
Delete the android support import(import android.support.annotations.NonNull
) and replace with it with the AndroidX import.
import androidx.annotations.NonNull
(I don't recall the exact import statement but you can google and get it)
Thats it, All the best!!