4

I'm trying to remove all the duplicates to keep it under 64K limit (now I have 65239, which is not good, because, in this case, I need to use multidex, which requires yet another dependency), but I could not find any information on how to remove modules from sub-groups.

For example, almost every sub-dependency under com.android.support:support-v4:26.1.0 has com.android.support:support-compat:26.1.0, which I need to remove because com.android.support:support-v4:26.1.0 already has one in the root, and this one I need to keep.

// Update: The following thread gradle - library duplicates in dependencies discuss a different problem the one which involves different versions of dependencies. I do not have that problem, all the dependencies which I use have the version I need.

I need to remove all modules that flagged with (*)

+--- com.android.support:appcompat-v7:26.1.0
|    +--- com.android.support:support-annotations:26.1.0
|    +--- com.android.support:support-v4:26.1.0
|    |    +--- com.android.support:support-compat:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- android.arch.lifecycle:runtime:1.0.0 -> 1.0.3
|    |    |         +--- android.arch.lifecycle:common:1.0.3
|    |    |         |    \--- com.android.support:support-annotations:26.1.0
|    |    |         +--- android.arch.core:common:1.0.0
|    |    |         |    \--- com.android.support:support-annotations:26.1.0
|    |    |         \--- com.android.support:support-annotations:26.1.0
|    |    +--- com.android.support:support-media-compat:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- com.android.support:support-compat:26.1.0 (*)
|    |    +--- com.android.support:support-core-utils:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- com.android.support:support-compat:26.1.0 (*)
|    |    +--- com.android.support:support-core-ui:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- com.android.support:support-compat:26.1.0 (*)
|    |    \--- com.android.support:support-fragment:26.1.0
|    |         +--- com.android.support:support-compat:26.1.0 (*)
|    |         +--- com.android.support:support-core-ui:26.1.0 (*)
|    |         \--- com.android.support:support-core-utils:26.1.0 (*)
|    +--- com.android.support:support-vector-drawable:26.1.0
|    |    +--- com.android.support:support-annotations:26.1.0
|    |    \--- com.android.support:support-compat:26.1.0 (*)
|    \--- com.android.support:animated-vector-drawable:26.1.0
|         +--- com.android.support:support-vector-drawable:26.1.0 (*)
|         \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.android.support:recyclerview-v7:26.1.0
|    +--- com.android.support:support-annotations:26.1.0
|    +--- com.android.support:support-compat:26.1.0 (*)
|    \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.android.support:design:26.1.0
|    +--- com.android.support:support-v4:26.1.0 (*)
|    +--- com.android.support:appcompat-v7:26.1.0 (*)
|    +--- com.android.support:recyclerview-v7:26.1.0 (*)
|    \--- com.android.support:transition:26.1.0
|         +--- com.android.support:support-annotations:26.1.0
|         \--- com.android.support:support-v4:26.1.0 (*)
+--- com.google.guava:guava:23.3-android
|    +--- com.google.code.findbugs:jsr305:1.3.9
|    +--- com.google.errorprone:error_prone_annotations:2.0.18
|    +--- com.google.j2objc:j2objc-annotations:1.1
|    \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
+--- com.jakewharton:butterknife:8.8.1
|    +--- com.jakewharton:butterknife-annotations:8.8.1
|    |    \--- com.android.support:support-annotations:25.3.0 -> 26.1.0
|    \--- com.android.support:support-annotations:25.3.0 -> 26.1.0
+--- android.arch.persistence.room:runtime:1.0.0-rc1
|    +--- android.arch.persistence.room:common:1.0.0-rc1
|    +--- android.arch.persistence:db-framework:1.0.0-rc1
|    |    \--- android.arch.persistence:db:1.0.0-rc1
|    +--- android.arch.persistence:db:1.0.0-rc1
|    \--- android.arch.core:runtime:1.0.0-rc1
|         \--- android.arch.core:common:1.0.0 (*)
+--- android.arch.lifecycle:extensions:1.0.0-rc1
|    \--- android.arch.lifecycle:runtime:1.0.3 (*)
\--- project :library

my gradle dependencies:

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation ('com.android.support:recyclerview-v7:26.1.0') {
    exclude group: 'com.android.support', module: 'support-compat'
    exclude group: 'com.android.support', module: 'support-core-ui'
}
implementation 'com.android.support:design:26.1.0'

implementation ('com.google.guava:guava:23.3-android')
implementation ('com.jakewharton:butterknife:8.8.1') {
    exclude group: 'com.android.support', module: 'support-compat'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-rc1'
annotationProcessor 'android.arch.lifecycle:common-java8:1.0.0-rc1'

implementation ('android.arch.persistence.room:runtime:1.0.0-rc1') {
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude group: 'com.android.support', module: 'support-core-utils'
}

implementation ('android.arch.lifecycle:extensions:1.0.0-rc1') {
    exclude group: 'android.arch.lifecycle:', module: 'runtime'
    exclude group: 'android.arch.core', module: 'common'
    exclude group: 'android.arch.core', module: 'runtime'
    exclude group: 'com.android.support', module: 'support-fragment'
    exclude group: 'android.arch.lifecycle', module: 'common'
}


testImplementation ('junit:junit:4.12')
testImplementation 'org.mockito:mockito-core:2.11.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'android.arch.persistence.room:testing:1.0.0-rc1'
testImplementation 'android.arch.core:core-testing:1.0.0-rc1'

implementation (project(':library')) {
    exclude group: 'com.google.guava', module:'guava'
    exclude group: 'junit', module: 'junit'
}
Katherine
  • 576
  • 1
  • 7
  • 19
  • Possible duplicate of [gradle - library duplicates in dependencies](https://stackoverflow.com/questions/30648172/gradle-library-duplicates-in-dependencies) – Cameron Downer Jul 19 '18 at 12:35
  • 1
    What is your gradle version? Curious how you got that list of dependencies with `*`? I'm also trying to clean up my build files with a similar issue, and `gradle -q dependencies myProject:dependencies --configuration implementation` is not showing these duplicates, even though they do in fact exist in the parent project as well. – topher217 Aug 12 '21 at 05:00

0 Answers0