Android Lint is a good check tool that can help developers to check a lot of problems, which are very useful for checking the duplicate resource files of Android projects.
1, the use of the command line
Android Lint has a lot of commands, which can be found on the Internet. Today, the main use of check, the purpose of this command is to do only one or a few types of checks, such as only check the useless resources "lint--check unusedresources <project dir>". As for what types of checks you have, you can enter the command "lint--list" to view it, or you can enter the command "lint--show" to see a detailed description. We can also save the results as a file, so as to view them, here is a simple example:
Lint--simplehtml <savefile>--check unusedresources <project dir>
This allows you to examine duplicate resources under a project and save the results as HTML files for easy viewing (file paths do not need to be quoted).
2. Use under Idea
There are lint plugins under Eclipse, and there are a lot of related information on the Internet, but there are few related documents for idea. Idea has already supported Android lint, how to use it?
Right-click in the project, and in the context menu that appears, there is "Analyze"--"Run inspaction by Name ...". Enter the type of check you want to perform in the pop-up search window, such as "Unused Resources". Do not need to enter all should be automatically found, the click will pop up "inspaction scope" Selection window, select the scope of inspection, general selection of the entire project or module. Under the "Inspaction scope" window can also set the file filter, select OK after the click OK to start checking. You can then remove duplicate resources based on the results of the inspection.
3, Idea Project check not whole problem.
The Android project check for idea is a problem, whether using the command line or idea to bring the plugin to check the duplicate resources, according to the results can be found that the inspection is not comprehensive, not checking the picture resources. But some documents on the Internet are very clear lint can check the picture resources, then what is the problem?
In fact, the idea of the Android project structure problem, idea created by the Android project built will find R.java and other temporary files inside is actually empty, and the image resource check needs to be based on R.java this file to check. So where is the real R.java file for the idea project?
Its location is "c:\users\<username>\." Intellijidea13\system\compile-server\<projectname_*****>\targets\java-production\<projectname>\ Android\generated_sources\aapt\<packagename>\r.java ".
I did a simple study and found a more awkward solution. The exact solution to the command line and idea is somewhat different:
(1) under the command line. In the project, create the Gen folder, under which the package name corresponds to the folder, and then copy the R.java to the following. Then you can use lint to check it out. Because the Android default file structure R.java file is under Gen, so lint will go to this folder to find R.java files.
(2) under idea. Similar to the command-line approach, but the folders that exist for R.java are different depending on the type of project you create. For example maven project under "Target\generated-sources\r" (Want to know the R.java file location of this project, can be in the project right-click menu "Open Modules setting" and "modules", Select "Android" under the corresponding module and select the "Generated Sources" tab in the right window, you can see the corresponding settings below, or you can modify it. )。 Copy the R.java to the corresponding folder to replace the empty R.java file, and then check the image resource using the idea's lint.
A small summary of the reason why the idea project will be problematic, or idea does not put temporary files such as R.java in the project directory, which is also a feature of idea. The above solution is also clumsy, do not know whether there is a more effective and convenient way, if someone knows that hope can be pointed. And there is a file, that is, the duplicate part of the Styles.xml file is still undetectable, does anyone know what the problem is?