Android Studio has now been updated to version 1.4, which is a powerful feature of Google's officially recommended IDE, which provides a set of static code analysis tools that can help us examine issues in our projects and enable us to develop more prescriptive apps. It can check out whether there are hardcode hard-coded in the XML file, resources not used by unused resource, bugs that probable bugs, and so on. So now let's test the use of it to see:
Use the Android lint to find the inspect code check Codes option in the Analyze directory click
Then the following box pops up, in this list option we can select the range of inspect code, click OK
After the analysis is complete, we can see the results of the inspection in the inspection column.
Among them, we can see from the test results that it will give all the code in this project is not standardized, redundant resources, possible bugs, or some other problems, and then give the revised recommendations for our reference, although these issues do not affect the normal operation of the app, However, this is very important for the normative and maintenance of the project.
We can see from the test demo, this project exists hardcode, unused resources and spelling spelling problems, click on the corresponding problem after the specific location for us to modify, so this tool can make the project has normative development.
Check tips for customizing Android lint
We know that when we write the layout in an XML file, if we write the string directly on the Text property in a TextView, and the value written on the Textsize property is in DP, then there will be a suggestion in the AS, such as:
You can see that this tip is not obvious, so we can change the level of the cue by changing the corresponding severity level, such as:
The default HardCode severity level is warning, we modify the severity level of HardCode to error, then the error level will alert us when there is a hard code:
Then modify the Testsize if the severity level using DP is:
After the modification is complete, we can see that the hint is marked with a wavy red line, which is more intuitive, such as:
In addition, there are many Android lint can be set up on their own, interested can go to try, of course, this is only a hint suggesting the role, and will not affect the normal operation of the program.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. Reprint Annotated Source: http://blog.csdn.net/u010687392
Android Studio uses lint for code checking