Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
like image 637
Rushi M Thakker Avatar asked Nov 24 '25 20:11

Rushi M Thakker


1 Answers

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.

like image 164
albert c braun Avatar answered Nov 27 '25 08:11

albert c braun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!