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

6

19

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.

Vaticinal answered 12/3, 2020 at 6:53 Comment(0)
M
8

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

Mandler answered 17/8, 2020 at 5:55 Comment(1)
git-scm.com/docs/git-clean -x: ... This allows removing all untracked files, including build products... -f: ... git clean will refuse to delete files or directories unless given -f or -i... -d: ... Specify -d to have it recurse into such directories as well...Wattenberg
B
3

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.

Buskus answered 10/5, 2020 at 19:15 Comment(1)
i just hit git clean -xfd + "Invalidate caches and restart" and flutter pub get after it got back up and it worked for meConveyancer
M
3

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

Melodee answered 27/2, 2021 at 19:17 Comment(0)
P
1

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

Patman answered 8/6, 2020 at 7:35 Comment(0)
V
0

As it seems it has some problems with androidx libraries! I backed from androidx and it works without error in kotlin and java both.

Vaticinal answered 12/3, 2020 at 7:59 Comment(2)
You backed to what?Balneology
I mean when I backed from androidx, it works again.Vaticinal
T
0

Downgrade from Android Studio's Kotlin plugin from 1.3.70 to 1.3.61 solved the problem for me

Tier answered 19/3, 2020 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.