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 :)
You can easily search for unused resources from Android Studio. Just press Ctrl Alt Shift i and type "unused resources" (without quotes). That will execute lint.
The lint tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. When using Android Studio, configured lint and IDE inspections run whenever you build your app.
To utilize Lint or just run inspections in your project, add Lint inspection to the lint. xml file or manually pick the list of issues to be configured by Lint in your project using Android Studio. Configure the lint file: Add the list of issues to be configured in the lint.
Module and file-specific preferences Run the lint tool on your module by right-clicking on your module folder or file in the Project View and selecting Analyze > Inspect Code. This displays the lint inspection results with a list of issues that lint detected in your module.
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.
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