android:minsdkversion="8",自动检查android:minSdkVersion的违规行为

看起来android lint工具执行了一些检查(感谢上面评论中的@CommonsWare):

$which lint

/android-sdk-macosx/tools/lint

$lint myProjectDir --check NewApi

Scanning .: .....

No issues found.

从SDK Tools Revision 21开始,您似乎也可以将其作为ant lint运行.

似乎Lint有各种不错的输出格式!通过–xml等与Jenkins集成……

另外,在ant.properties中,你可以设置这样的东西,让javac执行一些类似lint的检查:

java.compilerargs=-Xlint:all

目前还不清楚javac是否报告像lint这样的事件 – 检查NewApi,但它至少会报告[弃用]条目. (如果您找到javac报告的参考,请发表评论.)

对于后代,这里是lint的NewApi检查器的描述:

$lint --show NewApi

NewApi

------

Summary: Finds API accesses to APIs that are not supported in all targeted API

versions

Priority: 6 / 10

Severity: Error

Category: Correctness

This check scans through all the Android API calls in the application and

warns about any calls that are not available on all versions targeted by this

application (according to its minimum SDK attribute in the manifest).

If you really want to use this API and don't need to support older devices

just set the minSdkVersion in your AndroidManifest.xml file.

If your code is deliberately accessing newer APIs, and you have ensured (e.g.

with conditional execution) that this code will only ever be called on a

supported platform, then you can annotate your class or method with the

@TargetApi annotation specifying the local minimum SDK to apply, such as

@TargetApi(11), such that this check considers 11 rather than your manifest

file's minimum SDK as the required API level.

这里有一些关于lint的有用链接:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值