We use it directly in our company projects, and the results are good! Share the script code, hoping to help Android Developers. Note: For python beginners, the development environment is Sublime Text 2, and Ctrl + B is used directly. It has not been debugged in other environments. It should be similar to ^ copy the code ################################## ############### environment: win + python 2.7 # Author: Ma bo # Email: mabo02@baidu.com # Department: hao123-Wireless # Note: The first use of lint analysis will take a few minutes, please be patient. # Clean the project before use to ensure that dex is regenerated under the project bin, # So that lint can be analyzed. If you want lint to re-analyze redundant # resources, you need to delete (2) txt record files, (1) (3) (4) need # manually set according to our actual project. # If an error is reported (rarely #) when a file is missing in the project after the resource is cleared, use svn to restore the file. ######################################## ######### Import subprocess import reimport osimport timeimport thread # (1) project location projectPath = "D: \/hao123 \/code \/client-android" # (2) lint output txt record file txt = "D: \/hao123_unused_res.txt "# (3) Regular Expression, clear unnecessary jpg/png/xml in drawable and layout, # exclude files starting with sailor _ | wenku _ | zeus _ | bdsocialshare _ | floating_life _ | weather_info_icon _ | anthology _ regex = re. compile (r "^ res \ (drawable (-land )? (-[Xn]? [Mhlo] (dpi) | layout )? \\(?! (Sailor _ | wenku _ | zeus _ | bdsocialshare _ | floating_life _ | weather_info_icon _ | anthology _) [0-9a-zA-Z _ \.] *\. (jpg | png | xml) ", re. IGNORECASE) # (4) lint. bat location lint = "D: \/sdk \/tools \/lint. bat "isgotTxt = Falsedef timer (interval): while not isgotTxt: print 'lint is analyzing: % s' % time. ctime () time. sleep (interval) if not OS. path. exists (txt): thread. start_new_thread (timer, (5,) cmd = lint + '-- check "UnusedResources" "' + ProjectPath + '">' + txt p = subprocess. popen (cmd, shell = True, stdout = subprocess. PIPE, stdin = subprocess. PIPE, stderr = subprocess. PIPE) p. wait () fobj = open (txt, 'R') isgotTxt = Truei = 0j = 0for line in fobj: # print str (I) + ":" + line match = regex. match (line) if match: I = I + 1 filename = projectPath + "\/" + match. group (). replace ('\', "\/") try: print filename OS. remove (filename) j = j + 1 print "was deleted! "Partition t WindowsError: print" is not exists "pass print" Total Unused Resources = "+ str (I) print" Total deleted Resources = "+ str (j)