24

When running a Lint check on files in my project I often come across an error that looks like this (actual names of files redacted, but you'll get the idea):

Dependency from module 'name_of_my_project' on module 'some_3rd_party_library' could be probably be removed when complementary scope to 'File 'filepath_to_the_class_being_analyzed' also does not contain references on module 'some_3rd_party_library'

I get this error for every single library that isn't compiled with Gradle - i.e. libraries that have been imported whole into the project and then added as dependencies.

Facebook is a great example of a library that even if you wanted to compile it through Gradle you couldn't because they don't support it, and you need to run it as a local library - it seems like you'll then receive this "unnecessary module dependency" warning for every class that doesn't directly call Facebook.

So, the question is - what is the "proper" way of handling this error? Do I ignore it or am I supposed to change the code in some way to make it disappear?

Edit: in the preferences menu for Lint it describes the check as follows (in case this helps figure it out):

This inspection lists modules which contain redundant dependencies on other modules. These dependencies can be safely removed.

Janki Gadhiya
  • 4,492
  • 2
  • 29
  • 59
Jon
  • 7,941
  • 9
  • 53
  • 105
  • 1
    I just ignore it :P Android studio inspections are full of crap anyways. But if someone comes up with a solution I'll be more than interested to know too :) – ThanosFisherman Feb 25 '15 at 03:52

2 Answers2

1

There are known issues with the Lint checkers. I do not get this error in Android Studio 2.1.1. However, if you still do and you know it to be spurious, I would recommend going to Settings --> Editor --> Inspections --> Unnecessary Module Dependency and changing the Severity type from Warning to Info. This way you get a "clean lint build" and avoid a "broken windows" type of state due to bad lint algo. In fact, I've created a special category that has Info severity called Info Due To Bad Lint Algo to which I've assigned whatever I know to be spurious. This way I can periodically review those and see if they've been fixed.

You should report this to them btw, so there is some hope of it getting fixed... Good luck!

Creos
  • 2,445
  • 3
  • 27
  • 45
0

You can avoid lint checking using following block of code. Add following block of code into app build.gradle file inside android {}

lintOptions { checkReleaseBuilds false // set to true to turn off analysis progress reporting by lint quiet true // if true, only report errors ignoreWarnings true abortOnError false disable "ResourceType" }