I have used the lint(Analyze->Inspect Code...) and find out unused methods and resources. All the unused resources removed by Refractor->Remove unused R
Step 1
Generate usage.txt and mapping.txt with Proguard or R8
Add -printusage
to your proguard.pro file Run
./gradlew app:minifyReleaseWithProguard
or ./gradlew app:minifyReleaseWithR8
Step 2
Find class name records that is in usage.txt but not in mapping.txt, those are the unused classes that are removed by Proguard/ R8 It's not hard to write such algorithm but you can consider my approach using Binary Search Tree here