AppCompatActivity.onCreate 只能从同一个库组内调用 [英] AppCompatActivity.onCreate can only be called from within the same library group

查看:37
本文介绍了AppCompatActivity.onCreate 只能从同一个库组内调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 appcompat 25.1.0 后,我开始遇到奇怪的错误.

After upgrading to appcompat 25.1.0 I've started getting weird errors.

在我的代码中:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

我收到 lint 错误:

I get lint error:

AppCompatActivity.onCreate 只能在同一个库组内调用(groupId=com.android.support)

如何防止此类行为?

推荐答案

正如 Felipe 在他的 评论 这是一个错误 工具的预发布版本.

As Felipe already pointed out in his comment this is a bug in the pre-release version of the tools.

在 Google 发布修复程序之前,您可以暂时解决此问题,方法是将以下内容添加到项目模块的 build.gradle 文件中:

You can workaround it for now, until Google release a fix, by adding the following into your project module's build.gradle file:

android {
  lintOptions {
    disable 'RestrictedApi'
  }
}

值得注意的是,这可能会隐藏项目中的真实错误,因为它会抑制该类型的所有错误,因此更好的选择是降级 Android Studio 的版本和项目中使用的工具.

It's worth noting that this may hide true errors in your project as it suppresses all errors of that type, so the better option would be to downgrade the version of Android Studio and the tools used in the project.

这篇关于AppCompatActivity.onCreate 只能从同一个库组内调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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