Solution of filtering redundant resource files in Android project

This paper describes the solution of filtering redundant resource files in Android project with examples, which is of great practical value! The specific description is as follows:

Many developers often encounter this situation during the development of Android projects: the interface developers release a new version of the resource package, but some pictures have been changed and some pictures have been deleted. However, when implementing, the developers just overwrite the new resources into the original resource folder. With the release of the version, There are more and more useless resources accumulated in drawable or values. When the official version is finally released, you want to delete these redundant files, so you have to check them one by one to see whether they are useful, and then decide whether to delete them.

In view of this, it is necessary to automate the detection process!

The first thing that comes to mind when dealing with this kind of problem is the shell script. The following is a section that uses the shell script to automatically detect whether the file is used and automatically delete the unused file:

The above code is very simple. First list all the files under drawable (or you can change it to any directory), then traverse the entire directory, detect whether there is the use of '@ drawable / $filename' format for each file (you can change it to any format), and delete the file if it is not used. When using, you need to put this script in a directory at the same level as res.

This code can also be used in any other place where unused / used files need to be detected. Just modify the corresponding directory and matching pattern. Or for general purposes, you can write all configurations in one configuration file or pass the configuration as a parameter.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>