【问题标题】:Android lint: does not show message “Call requires API level 17 (current min is 14)”Android lint:不显示消息“调用需要 API 级别 17(当前最小值为 14)”
【发布时间】:2016-11-16 02:48:31
【问题描述】:

在某些情况下,我发现 android studio lint 没有显示消息“Call requires API level xxx (current min is xxx)”。

public class TestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_enter_leave_wifi);
    if(isDestroyed()){

    }
}

private class Test {
    Test(){
        if (isDestroyed()){

        }
    }
}

我发现onCreate的isDestroyed()中有错误提示,但是Test的构造函数中没有这样的错误提示

如何解决这个问题?

更新:

当前的 minSdkVersion 是 14。这就是为什么 onCreate 中需要 17 的 isDestroyed() 会给出错误提示

【问题讨论】:

  • 您的最低要求是多少。 API 目标?
  • 该代码永远不会被调用。因此,问题永远不会发生。 -> 尝试实例化Test,看看它是否会改变分析。
  • 我试图创建一个新的Test实例,但它仍然没有显示错误提示

标签: android lint


【解决方案1】:

您要执行的功能需要更高的 API 级别访问权限,而不是您当前不可用该功能/访问权限的最低级别。

为了实现这一点,只需在 app:gradle 文件中将当前最低 API 级别更改为所需的级别。然后重新编译项目。

祝你好运

【讨论】:

  • 我已经将最小 sdk 设置为 14,这就是 onCreate 中的 isDestroyed() 给出错误提示的原因。我担心的是第二个 isDestroy() 没有显示错误提示
  • 除了不显示提示之外,您是否遇到任何错误/问题???所需的 API 级别是多少?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多