Rushi M Thakker
Rushi M Thakker

Reputation: 679

AppCompatActivity is not assignable to Activity

After a year of coding in android and everything working perfectly till yesterday. Today, I found something really strange after upgrading to gradle 3 alpha 2 and studio 3 build 2.

This is the declaration of one of the activities throwing error: This

This is the activity code: This

What is wrong?

EDIT

appcompat dependency:

  compile 'com.android.support:appcompat-v7:23.2.1'

Upvotes: 3

Views: 1089

Answers (2)

Pyae Phyo Aung
Pyae Phyo Aung

Reputation: 270

As an alternative ways, you can simply change the class that you extended to Activity class instead of AppCompatActivity.

Upvotes: 0

albert c braun
albert c braun

Reputation: 2710

Maybe this will help:

In the app build.gradle, change compileSdkVersion and targetSdkVersion to 25.

Also upgrade the version of the appcompat library to 25.3.1:

compile 'com.android.support:appcompat-v7:25.3.1'

UPDATE 05/31/2017:

As @cricket_007 pointed out to me in comments, it isn't caused by a problem with the non-existence of AppCompatActivity, as I had theorized (in comments).

And while I have not been able to track it down, it looks like the lint checking is behaving differently or misbehaving on Android Studio 3 Preview, or in the 3.0.0 alpha2 version of Android Gradle Plugin, some build tools versions (or somewhere).

If your code is compiling ok (in spite of the "assignable" complaint appearing in AndroidManifest.xml) and you want to keep using Android Studio 3 Preview, maybe it's worth trying to suppress "AndroidDomInspection" on that activity tag for now:

<!--suppress AndroidDomInspection -->
<activity android:name=".admin.AdminChangeCoach">
    . . .
</activity>

But, FWIW, I also agree with @cricket_007's earlier comment: I'm not using Android Studio 3 for production yet either.

Upvotes: 5

Related Questions