android - AppCompatActivity.onCreate 只能在同一个库组内调用

标签 android android-lint android-appcompat

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

在我的代码中:

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

我收到 lint 错误:

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

如何防止此类行为?

最佳答案

正如之前的回复所强调的那样,这是错误。我建议不要在项目范围内禁用特定的 lint 警告,而仅针对该方法。如下注释您的方法:

@SuppressLint("RestrictedApi")
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    //your code here
}

关于android - AppCompatActivity.onCreate 只能在同一个库组内调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41150995/

相关文章:

android - 错误 : cannot access ListViewCompat class file for android. support.v7.internal.widget.ListViewCompat 找不到

android - ActionBarActivity 在按下硬件菜单按钮后关闭。没有堆栈跟踪

android - 将 espresso-contrib 添加到 androidTestImplementation 会产生依赖性/约束错误

android - Kotlin 中的 String 属性可以有多长?

android - SIP 如何在蜂窝网络上工作?

安卓 Lint 工具

gradle - 我可以将lint-result.xml上传到Android Gradle项目中的SonarQube吗?

android - Windows 10 升级后 Genymotion 错误

java - 无法向对象添加/删除位图

android - 当我将 lint.xml 文件从模块目录移动到项目目录时找不到