First, call the Android Lint command to find out which resources are not used and generate a list of listings:
Command:lint–check "Unusedresources" [Project_path] > Result.txt
after execution, a manifest file is generated, which reads as follows:
Use code to automatically delete useless files:
public class Delaction
{public
static void Main (string[] args)
throws IOException
{
String ProjectPath = "* * *";
BufferedReader reader = new BufferedReader (new FileReader ("Result path"));
String Line;
int count = 0;
while (line = Reader.readline ())!= null)
{
if (line.contains ("unusedresources") &&!line.contains ( "Res/value") &&!line.contains ("AppCompat"))
{
count++;
int end = Line.indexof (":");
If (end!=-1)
{
String file = line.substring (0, end);
String f = projectpath + file;
Boolean flag =
new File ("spelling out the full path of the file" "+ F.replace (" * * * ")). Delete (); System.out.println ("" "spelling out the full path of the file" "+ F +" =>del=> "+ Flag);}}}}
We often have to repeat the above operation many times in order to truly eliminate the useless resource files in the project.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.