eclipse为什么不抱怨这种弃用的方法?

时间:2014-03-17 21:56:19

标签: android eclipse android-lint

在我的manifest.xml中,我定义了:

    <uses-sdk android:minSdkVersion:"8" android:targetSdkVersion:"8" />

并在Android的View类文档中说过:

    setBackground(Drawable) 
    // ADDED IN API LEVEL 16

此方法已在api级别16中添加。但是当我在我的代码中使用它时,eclipse不会发出任何投诉,我的应用程序在运行api 16的设备上崩溃。

我哪里错了?

3 个答案:

答案 0 :(得分:3)

你可能以8版为目标,但用19编译。

答案 1 :(得分:2)

您可以像这样配置项目的Android Lint首选项:

  1. 转到项目 - &gt;属性 - &gt; Android Lint首选项
  2. NewApi设置为严重性error
  3. 点击应用按钮
  4. enter image description here


    然后它应该将setBackground方法加下划线并将其标记为错误。这在我的项目中对我有用。

答案 2 :(得分:0)

您正在针对高于16的版本进行编译。转到项目根目录中的project.properties文件,将行target=android-someNumber更改为target=android-8