44

I get a lot of these warnings when building my project with gradle. I see https://stackoverflow.com/a/15794650/864069, but I'm unclear how to silence these. It sounds like any version of these things I'm depending on is getting stripped out in favor of the version packaged in android.jar.

I suppose that's okay, but I really would like to shut these up so that the things I see are real problems only.

So, specifically, I'm curious:

  1. Does this indicate an issue? Seems like definitely not.
  2. How do I shut this up?
  3. Doesn't everyone see this set of warnings? I'm skeptical that the entire universe of people using gradle + android.Log is seeing this set of warnings.
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for robolectric as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for robolectric as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.3 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Community
  • 1
  • 1
secureboot
  • 1,776
  • 4
  • 20
  • 32
  • I noticed that I get these when the app has exceeded the 64K Dex limit. Android Studio could have made this a little bit less cryptic, but look for `Unable to execute dex: method ID not in [0, 0xffff]: 65536`. If you've exceeded the 64K Dex limit, than that error will show at the bottom of the grade build messages.... of course the useful stuff is at the bottom /rolleyes – Someone Somewhere Apr 01 '15 at 21:50

2 Answers2

86

I'm unsure if this can create issues. The best thing to do is to follow the suggestion in the warning, or exclude the dependency entirely (your point #2, which I've answered below).

I've been seeing these warnings as well, specifically the 'commons-logging' one.

What the answer in the thread you linked too is saying is that you should ignore these dependencies since the Android APIs include them already (I think. Correct me if I'm wrong).

For example if you are specifically requiring commons-logging (or another that gives a similar warning) remove it from your list.

build.gradle file:

dependencies {
    ...
    compile 'commons-logging:commons-logging:1.1.3' #Remove this line; you don't need it.
    ....
}

Also, if you have a dependency that requires commons-logging as a transitive dependency, you should exclude it as well.

Example:

dependencies {
    ...
    compile 'some.package.that:requires_commons_logging:1.2.3'
    ....
}

becomes

dependencies {
    ...
    compile ('some.package.that:requires_commons_logging:1.2.3') {
        exclude group: 'commons-logging', module: 'commons-logging'
    }
    ....
}

An easy way to completely exclude it can be done by adding this to your build.gradle file as well, without having to exclude it in each dependency:

configurations {
    all*.exclude group: 'commons-logging', module: 'commons-logging'
}

Finally, to view the dependency tree (and to see what each of your dependencies transitively import on their own which can conflict, which can be very useful), use this command from the root of your project:

./gradlew :your_module_name:dependencies
maraci
  • 1,090
  • 7
  • 11
  • by excluding the `commons-logging` I was able to get a little bit further with adding `xwalk_core_library_java_app_part.jar` Thanks – Someone Somewhere Apr 01 '15 at 21:33
  • 3
    To answer to your (answer's) question: yes, it can cause issues. Such as the one I was just experiencing with the Android AWS framework (com.amazonaws:aws-android-sdk-core and others). My application would crash because of a transitive dependency to commons-logging in the AWS framework. Using the "exclude group: 'commons-logging'" line on all the amazonaws libraries imported (using Gradle) from the Maven repository solved my issue. – Pelpotronic Aug 19 '15 at 02:36
  • Thanks Pelpotronic! I'll update my answer a little later with your findings – maraci Aug 19 '15 at 16:45
  • 1
    I second @Pelpotronic observation. Due to mismatched dependencies I had a crash upon launch when using AWS simpledb. – Álex May 12 '16 at 15:42
10

If you want to silent the warnings, you have to add this in your build.gradle for each dependency :

exclude group: 'org.apache.httpcomponents', module: 'httpclient'

It will be :

dependencies {
    ...
    compile ('some.package.that:requires_commons_logging:1.2.3') {
        exclude group: 'commons-logging', module: 'commons-logging'
    }
    ....
}
Sigvent
  • 297
  • 4
  • 17