无法将AppCompatActivity分配给Activity [英] AppCompatActivity is not assignable to Activity

查看:80
本文介绍了无法将AppCompatActivity分配给Activity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过一年的android编码工作,直到昨天一切正常.今天,在升级到gradle 3 alpha 2和studio 3 build 2之后,我发现了一些非常奇怪的东西.

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:

这是活动代码:

怎么了?

编辑

appcompat依赖项:

appcompat dependency:

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

推荐答案

也许会有所帮助:

在应用程序build.gradle中,将compileSdkVersion和targetSdkVersion更改为25.

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

还将appcompat库的版本升级到25.3.1:

Also upgrade the version of the appcompat library to 25.3.1:

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

2017年5月31日更新:

UPDATE 05/31/2017:

正如@ cricket_007在评论中向我指出的那样,这不是由于我理论上(在评论中)提出的AppCompatActivity不存在引起的.

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).

虽然我无法对其进行跟踪,但看起来绒毛检查在Android Studio 3 Preview上或在Android Gradle Plugin的3.0.0 alpha2版本中有一些构建工具版本(或某处).

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).

如果您的代码可以正常编译(尽管在AndroidManifest.xml中出现可分配的"投诉),并且您想继续使用Android Studio 3 Preview,那么现在暂时应该在该活动标签上取消显示"AndroidDomInspection"是值得的:

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>

但是,FWIW,我也同意@ cricket_007的早期评论:我也没有将Android Studio 3用于生产.

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

这篇关于无法将AppCompatActivity分配给Activity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆