Flutter Android studio build failing

  • A+
Category:Languages

My Android studio flutter project started giving cannot find symbol errors.

C:/Users/abc/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/firebase_messaging-2.2.0/android/src/main/java/io/flutter/plugins/firebasemessaging/FirebaseMe**ssagingPlugin.java:13: error: cannot find symbol import androidx.annotation.NonNull;**                           ^   symbol:   class NonNull   location: package androidx.annotation C:/Users/abc/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/firebase_messaging-2.2.0/android/src/main/java/io/flutter/plugins/firebasemessaging/FirebaseMessagingPlugin.java:14: error: package androidx.localbroadcastmanager.content does not exist import androidx.localbroadcastmanager.content.LocalBroadcastManager;                                              ^ C:/Users/abc/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/firebase_messaging-2.2.0/android/src/main/java/io/flutter/plugins/firebasemessaging/FlutterFir**ebaseInstanceIDService.java:9: error: package androidx.localbroadcastmanager.content does not exist import androidx.localbroadcastmanager.content.LocalBroadcastManager;** 

Anyone has an idea what is wrong ?

As suggested by other users I tried to refactor to AndroidX but still getting error even though it is compileSdkVersion 28. I also tried to invalidate cache and restart the android studio.

Flutter Android studio build failing

Gradle.properties Flutter Android studio build failing

 


If you are using cloud_firestore: ^0.9.0 Change the following

pubspec.yaml

Add firebase_core: '^0.3.0' to dependencies

android/build.gradle

Add mavenLocal() to buildscripts.repositories and allprojects.repositories

Add classpath 'com.google.gms:google-services:4.2.0' to buildscript.dependencies

android/grandle.properties

Add android.useAndroidX=true and android.enableJetifier=true

android/app/build.gradle

change compileSdkVersion to 28

change dependencies to

testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 

Add apply plugin: 'com.google.gms.google-services' at the bottom

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: