How to detect unused resources in Xamarin.Android?

Is there a way in Xamarin.Android to detect unused resources? I would like to specifically identify drawings that I no longer use.

I believe that Resource.designer.cs and R.java in \ obj can be used to create a program that does this, I'm just not sure if there is already such a way? On Android, you can usually use Lint to detect this, but it seems to detect everything as unused when specified in the Xamarin.Android project.

+6
source share
2 answers

You can use the lint tool with Xamarin.Android projects, we have a new xbuild / msbuild AndroidLintEnabled with this property set to true , or by adding it to the command line

/ p: AndroidLintEnabled = true

or adding it to .csproj

<AndroidLintEnabled> true </AndroidLintEnabled>

the android lint tool will run, and warnings / errors will be displayed as regular errors and xbuild / msbuild warnings.

+5
source

The only way I know is human work.

I think the best thing is to exclude all available files, compile, check for valid errors, add one by one, and the drawings will not be added, you will delete.

Yes, I know that a lot of work, but there is some kind of utility.

Another way is to search in all your projects for each file name. If the only location for this file is Resources, delete it.

Sorry, do not help with another solution :(

+1
source

Source: https://habr.com/ru/post/971015/


All Articles