Android-Lint检查的潜在问题
来源:互联网 发布:linux安装jdk1.7 编辑:程序博客网 时间:2024/05/21 10:54
转载地址:http://lxfgrace.iteye.com/blog/1693639
1.1问题描述-- Issue
Android-Lint所要检查的问题以Issue来描述。
Issue分9类(Category):Correctness/ Correctness: Messages / Security / Performance / Usability: Typography /Usability: Icons / Usability / Accessibility / Internationalization。
Issue以一个文本短语来作为id,对Issue的定制等操作都是基于id的。
Issue以Severity来标识该Issue的危害程度:Fatal / Error / Warning/ Information / Ignore。对Issue的忽略操作其实也就是降低它的Severity为Ignore。
1.2 检查的潜在问题
Android-Lint所检查的潜在问题,可以通过命令行$lint --show来获得所要扫描问题的详细列表。
下面简要列举Android-Lint所检查的常见问题:
[plain] view plaincopy
1. Correctness
1) DuplicatedIds
Layout中id应该唯一
2) NewApi
代码中使用的某些API高于Manifest中的Min SDK
3) InconsistentArrays
字符串国际化中,同一名字的的String-Array对应的item值不相同
4) Registered
Activity/Service/ContentProvider没有通过AndroidManifest注册
5) Deprecated
使用已经废弃的API
6) PxUsage
避免使用px,使用dp
2. Correctness:Messeges
1) MissingTranslation
字符串国际化不完全
2) ExtraTranslation
国际化的字符串,在默认位置(defaultlocale),没有定义
3. Security
1) SetJavaScriptEnabled
不确定你的程序中确实需要JavaScript就不要执行SetJavaScriptEnabled。
2)ExportedContentProvider/ExportedReceiver/ExportedService/ExportedActivity
ContentProvider/Receiver/Service/Activity的exported为true时,设置一个Permission,让使用者获取了Permission才能使用。
3) HardcodedDebugMode
不要在manifest中设置android:debuggable。
设置它,编译的任何版本都要采用指定的debug模式。不设置,编译Eng版本采用debug模式;编译User版本采用release模式。
4. Performance
1) DrawAllocation
避免在绘制或者解析布局(draw/layout)时分配对象。E.g.,Ondraw()中实例化Paint对象。
2) ObsoleteLayoutParam
Layout中无用的参数。
3) UseCompoundDrawables
可优化的布局:如包含一个Imageview和一个TextView的线性布局,可被采用CompoundDrawable的TextView代替。
4) UseSparseArrays
尽量用Android的SparseArray代替Hashmap
5) DisableBaselineAlignment
如果LinearLayout被用于嵌套的layout空间计算,它的android:baselineAligned属性应该设置成false,以加速layout计算。
6) FloatMath
使用FloatMath代替Math。
7) NestedWeights
避免嵌套weight,那将拖累执行效率
8) UnusedResources/UnusedIds
未被使用的资源会是程序变大,并且编译速度降低。
9) Overdraw
如果为RootView指定一个背景Drawable,会先用Theme的背景绘制一遍,然后才用指定的背景,这就是所谓的“Overdraw”。
可以设置theme的background为null来避免。
10) UselessLeaf/UselessParent
View或view的父亲没有用
5. Usability:Typography
1) TypographyDashes
特殊字符需用编码代替:“–”需要用“–”;“—”需要用“—”
2) TypographyEllipsis
特殊字符需用编码代替:“…”需要用“…”
3) TypographyOther
问题:“(c)”需要用“©”
6. Usability:Icons
1) IconNoDpi
Icon在nodpi和指定dpi的目录下都出现。
2) GifUsage
Image不要用GIF,最好用PNG,可以用JPG。
7. Usability
1) BackButton
Android中不要设计有Back的按钮,Android中一般有Back的硬按键。
2) ButtonCase
Button的“Ok”/“Cancel”显示大小写一定,不要全大写或全小写。有标准的资源的字符串,不要自己再定义,而要用系统定义的:@android:string/ok和@android:string/cancel
8. Accessibility
1) ContentDescription
ImageView和ImageButton应该提供contentDescription
9. Internationalization
1) HardcodeText
硬编码的字符串应该在资源里定义
2) EnforceUTF8
所有XML资源文件都应该以UTF-8编码
...
0 0
- Android-Lint检查的潜在问题
- android lint检查出现的问题
- Android-Lint 检查问题列表
- Android-Lint 检查问题列表
- Android-Lint 检查问题列表
- Android-Lint 检查问题列表
- 定制Android-Lint检查问题的现有规则
- 定制Android-Lint检查问题的现有规则
- 定制Android-Lint检查问题的现有规则
- 定制Android-Lint检查问题的现有规则
- 定制Android-Lint检查问题的现有规则
- android lint三部曲二:定制Android-Lint检查问题的现有规则
- android lint三部曲三:Android-Lint 检查问题列表
- PC-LINT检查的编译问题
- Android lint工具 检查的常见问题
- Android Lint 代码检查工具的使用
- Android Lint静态检查
- Android Studio打包APK是遇到的一些问题(Lint检查的错误)
- Fill-rate,Canvases and input 填充率,画布和输入—(Unity3d)
- Visual Studio 安装后如何启动
- HDU2874——Connections between cities 详解 (LCA,RMQ,数据结构,dfs序,并查集)
- 关于分布式系统的数据一致性问题
- 分蛋糕问题
- Android-Lint检查的潜在问题
- MFC_笔记
- DM8168 DVRRDK软件框架研究
- QCopChannel的用法
- mvc开发模式
- Java DecimalFormat
- js注意事项07
- ubuntu 修改时区
- Dijkstra最短路算法