Android-зависимость игнорируется для выпуска

Я получаю много этих предупреждений при создании моего проекта с помощью gradle. Я вижу qaru.site/info/122423/..., но я не понимаю, как их заставить замолчать. Это звучит как любая версия этих вещей, в зависимости от того, что я в порядке, убирается в пользу версии, упакованной в android.jar.

Я полагаю, что все в порядке, но я действительно хотел бы закрыть их, чтобы вещи, которые я вижу, являются реальными проблемами.

Итак, в частности, мне любопытно:

  • Это указывает на проблему? Кажется, точно не.
  • Как мне закрыть это?
  • Не все ли видят этот набор предупреждений? Я скептически отношусь к тому, что весь мир людей, использующих gradle + android.Log, видит этот набор предупреждений.
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

Ответ 1

Я не уверен, что это может создать проблемы. Лучше всего сделать это, чтобы следовать рекомендациям в предупреждении или полностью исключить зависимость (ваша точка № 2, на которую я ответил ниже).

Я тоже видел эти предупреждения, в частности, "общедоступный".

Какой ответ в потоке, на который вы ссылаетесь, говорит, что вы должны игнорировать эти зависимости, поскольку API Android уже включают их (я думаю, исправьте меня, если я ошибаюсь).

Например, если вам специально требуется commons-logging (или другое, которое дает аналогичное предупреждение), удалите его из своего списка.

build.gradle файл:

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

Кроме того, если у вас есть зависимость, которая требует коммонции в качестве транзитивной зависимости, вы также должны ее исключить.

Пример:

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

становится

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

Легкий способ полностью исключить его можно сделать, добавив это в свой файл build.gradle, не исключая его в каждой зависимости:

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

Наконец, чтобы просмотреть дерево зависимостей (и посмотреть, что каждая из ваших зависимостей транзитивно импортирует самостоятельно, что может конфликтовать, что может быть очень полезно), используйте эту команду из корня вашего проекта:

./gradlew :your_module_name:dependencies

Ответ 2

Если вы хотите отключить предупреждения, вы должны добавить это в свой build.gradle для каждой зависимости:

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

Это будет:

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