jafar_aml
jafar_aml

Reputation: 369

FragmentActivity which is a supertype of MainActivity can not be accessed

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?

Upvotes: 1

Views: 4988

Answers (6)

Hamed Karami
Hamed Karami

Reputation: 412

The issue is due to the missing Fragment dependency, as mentioned in the error message you sent. You just need to add this dependency.

Here’s the link to the official site: mvnrepository Or add this to your Gradle: runtimeOnly("androidx.fragment:fragment:1.8.5")

Upvotes: 1

Choppari Akhilesh
Choppari Akhilesh

Reputation: 11

Just remove the dependencies and undo the dependencies using ctrl+z

Upvotes: 1

mymarcosweb
mymarcosweb

Reputation: 23

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

Upvotes: 1

ISAIAH PIUS
ISAIAH PIUS

Reputation: 51

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'

Upvotes: 1

Hooman Abedi
Hooman Abedi

Reputation: 26

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.

Upvotes: 1

cmak
cmak

Reputation: 649

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.

Upvotes: 1

Related Questions