29

My app is split up in a main app and different library modules. When I run

./gradlew lint 

each module is checked independently and for each module a lint.xml file is generated. In the lint.xml files there were tons of unused resources warnings, but that resources are used in the main app. How can I configure lint to check globally in the app if a resources is used or not?

Thanks :)

sbo
  • 951
  • 2
  • 12
  • 25
  • 1
    Did you find any solution to this issue? I am facing the same issue. – Rocket Feb 28 '18 at 10:32
  • No, but I think it is ok, that each module is checked for separately. When your assets are only used in the main module, you have to move them to the main module. – sbo Mar 01 '18 at 20:35
  • Thank you for the response. I have resources which are in a common module and are used in more than one other module. And so I can't move it to one of these modules. – Rocket Mar 02 '18 at 11:21
  • Yeah this is still a problem. Surprising there isn't a good way to deal with this... – Jonathan Nov 22 '19 at 18:08
  • @Rocket I have exact same situation, I have resources module and can't move resources to their own module. Did you find a way to fix this? – Besat Mar 25 '22 at 17:01

2 Answers2

14

The trick is to only check your app component and the rest of the app recursively through there:

Enable recursive lint checks

android {
    lintOptions {
        checkDependencies true
    }
}

Only check app

./gradlew :app:lintDebug

This will not only fix the unused resources issues, but it's also faster since lint is only called once instead of once per module. This means that things like symbol resolution in the SDK are only done once.

Cristan
  • 12,083
  • 7
  • 65
  • 69
-2

This is the most common issue in Lint. Lint may not check the used resources in XML folders, in the custom view and also in the assets folder. To configure lint I can suggest you this links

  1. https://developer.android.com/studio/build/gradle-tips.html

  2. http://tools.android.com/tips/lint

  3. https://developer.android.com/studio/write/lint.html
Krunal Kapadiya
  • 2,853
  • 3
  • 16
  • 37
  • 2
    Sorry, but this is not an actual answer. If you know how to configure Lint to avoid these false positives, please include it in your answer (even if the linked documentations include the info). – Tamás Barta May 14 '18 at 13:58