resources.txt file is a file that will be generated if we build an app with shrinkResources enabled. It contains information about unused resources that we can remove. To produce it we need to do these:
- Empty DFM list in app/build.gradle → dynamicFeatures = []
- Enable ShrinkResources in app/build.gradle → shrinkResources = true
- Build the app → ./gradlew app:assemble
- Wait until the build is successful
- Locate resources.txt in app/build/outputs/mapping//resources.txt
- Remove all lines except line with format Skipped unused resource res/drawable-xxhdpi-v4/ic_launcher_background.png: 767 bytes (replaced with small dummy file of size 67 bytes)
- Modify those lines, extract only res/drawable-xxhdpi-v4/ic_launcher_background.png
- It takes 2 arguments,
- First argument is for the path of resources.txt
- Second argument is for the path of the android project, if it's not specified the default value for it is "."
- The command is java -jar /ResourceCleaner.jar [resources.txt path] [android project path] resources.txt**
If the build is failed, there's a possibility that some resources are used by a method or a class that is unused. You can delete the method or the class and try to rebuild again.