FragmentActivity which is a supertype of MainActivity can not be accessed

3.5k Views Asked by At

When I wanna create a new project in AS I get this error:

Cannot access 'androidx.fragment.app.FragmentActivity' which is a supertype of 'com.example.test123.MainActivity'. Check your module classpath for missing or conflicting dependencies

After that I can not build/rebuild or run my clean new project. any idea?

4

There are 4 best solutions below

0
Hooman Abedi On BEST ANSWER

i got the same issue with my gradle and project build/rebuild, the solution however is somehow random but i tried to remove the contents of my ".gradle" folder to force my project to download it from scratch.

After doing that in the AS i changed the gradle plugin version to a latest release (ex. alpha x.xx) in File -> Project Structure and rebuild project and then again reverted back to latest stable release and my project built without any issue.

2
cmak On

Check if you have the appcompat library in the app's build.gradle file. If it's still not working, try to invalidate caches and restart.

0
ISAIAH PIUS On

In my case this is what worked: In my build.gradle module dependencies, I changed

implementation 'com.google.android.material:material:1.4.0'

to

implementation 'com.google.android.material:material:1.6.1'
0
mymarcosweb On

In my case my laptop don´t connect to internet. I fixed this and worked.