Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access 'android.arch.lifecycle.LifecycleOwner' which is a supertype of 'com.ex.app.MainActivity'

I create a new flutter project in android studio then "open project" the android part of it, I met an error in MainActivity.kt however it builds successfully.

enter image description here

My class pathes are:

enter image description here

and finally my dependencies are:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.70"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

I would be grateful if someone could help me.

like image 277
Parisa Baastani Avatar asked Mar 12 '20 06:03

Parisa Baastani


4 Answers

I face same Problem, now it solved in my case

Step 1 : open your project in AndroidStudio
Step 2 : open Terminal and goto your project path in terminal
Step 3 : Hit this command 'git clean -xfd'
Step 3 : Goto : File -> Invalidate caches/restart

like image 193
Sanjayrajsinh Avatar answered Nov 19 '22 17:11

Sanjayrajsinh


You need to go to the flutter directory

rm -rf bin/cache/artifacts/engine/android*

Then go to project directory

flutter clean
flutter pub get

Also you can "Invalidate caches and restart" in Android Studio.

like image 21
whitebug Avatar answered Nov 19 '22 18:11

whitebug


I had the same issue and was trying to debug for ages. The simple solution was to go to " File > Invalidate Caches/ Restart ".

like image 2
GraSim Avatar answered Nov 19 '22 17:11

GraSim


You need to enable the beta feature "Enable code completion, navigation, etc. for Java / Kotlin" at: Preferences -> Languages & Frameworks -> Flutter (bottom).

like image 1
jayme Avatar answered Nov 19 '22 16:11

jayme