【问题标题】:why does this work on api 21 when the error says it shouldn't当错误说它不应该时,为什么这在 api 21 上有效
【发布时间】:2019-09-05 15:47:02
【问题描述】:

我刚刚将我应用中的 gradle 插件升级到了 3.2 版。

我现在收到一个 lint 错误,指出无法使用已在我的应用程序中使用的 FloatProperty。我的 gradle 文件中的最低 API 级别是 21。错误是:

Class requires API level 24 (current min is 21)

我的问题是,为什么即使在我运行 API 22 的测试手机上也能正常构建和运行?

【问题讨论】:

  • 你的 compileSdkVersion 是什么?
  • compileSdkVersion 28
  • FloatingProperty 的导入语句看起来像什么?
  • 导入 android.util.FloatProperty

标签: android android-api-levels


【解决方案1】:

您的compileSdkVersion 本身是 28 与哪些设备可以和不能运行您的应用程序无关。通常,您将其设置为最新版本的 Android SDK。

通常,当您尝试使用比您的minSdkVersion 更新的东西时,开发工具会即时警告您。您可以定期运行完整的 Lint 检查以重新确认。

targetSdkVersion 有助于向后兼容,通常我的描述是“这是您在编写代码时考虑的 Android 版本”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-04
    • 2012-01-19
    • 2016-08-22
    相关资源
    最近更新 更多