AndroidX.Annotation - Missing class, RequiresApi

Viewed 1226

In my Flutter apps I have frequently used the Connectivity plugin to check the current online state of the host device. Up until recently this has always worked just fine. However, with the latest Flutter upgrade, version 1.22.2 I find that attempting flutter run gives the error

pathto:\flutter.pub-cache\hosted\pub.dartlang.org\connectivity-0.4.9+5\android\src\main\java\io\flutter\plugins\connectivity\ConnectivityBroadcastReceiver.java:16: error: cannot find symbol import androidx.annotation.RequiresApi

and then

                       ^

RequiresApi

I fail to see why this is happening. The AndroidX developer docs certainly talk of this class. I should mention that I specity minSdkVesion 23 with targetSdkVersion as 28. Flutter doctor reports no errors, Android SDK version 30.0.2 and Android studio 4.

Why is this happening and how might I be able to fix it?

1 Answers

in android/gradle.properties add below two line. in my case solve issue using this.

android.useAndroidX=true android.enableJetifier=true

Related