Is there a way in Xamarin.Android to detect unused resources? I'd like to specifically detect drawables that I'm no longer using.
I believe that the Resource.designer.cs and the R.java in \obj could be used to create a program that does this I'm just not sure if there is a way already out there? In Android you can normally use Lint to detect this but it appears to detect everything as unused when pointed at a Xamarin.Android project.
In Android Studio Menu > Refactor > Remove Unused Resources... Select the resources you want to remove. You can exclude resources you want to keep by right-clicking on the resource item. Use Do Refactor to remove all Resources at once.
You can use the lint
tool with Xamarin.Android projects, we have a new xbuild/msbuild property AndroidLintEnabled
with this property set to true
either by adding it to a command line
/p:AndroidLintEnabled=true
or by adding it to the .csproj
<AndroidLintEnabled>true</AndroidLintEnabled >
the android lint tool will be run and the warnings/errors will be output as normal xbuild/msbuild errors and warnings.
The only way I know, is human work.
I think that the better, way is exclude all drawable files, compile, check drawable errors, add one by one and the drawables don't be added you will delete.
Yeah, I know is a lot of work, but there any util that helps.
Other way, is search in all your Project every drawable file name. If the only place you get this file is Resources, delete it.
Sorry, don't help you with another solution :(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With