10

Android Studio is complaining with Cannot access androidx.activity.ComponentActivity in redline, but it's compiling and running fine. I came across many SO posts like this and all suggests clearing cache, removing .idea and .gradle files, clean project. I've tried everything and I still keep getting this. Am I missing something?

enter image description here

Arun Kumar Nagarajan
  • 2,347
  • 3
  • 17
  • 28

3 Answers3

1

For me updating to the last appcompat dependency helped.

Artem
  • 896
  • 1
  • 11
  • 16
1

for me downgrading appcompat version to 1.4.2 fixed the problem

you should add this to your build.gradle

implementation 'androidx.appcompat:appcompat:1.4.2'
Amin
  • 73
  • 8
0

check the package of AppCompatActivity.

In my situation, the Activity extends RxAppCompatActivity from the rxlifecycle library.

But the parent class of RxAppCompatActivity in rxlifecycle2 is android.support.v7.app.AppCompatActivity.

I change to the 'rxlifecycle3' and the problem is soloved.

tesla1984
  • 541
  • 2
  • 8