gradle - library duplicates in dependencies
To find duplicate dependencies or its required dependencies, you can visualize library dependencies in tree. Execute gradle command as below.
gradle -q dependencies yourProject:dependencies --configuration compile
Note that, run gradlew
in Windows as below.
gradlew -q dependencies yourProject:dependencies --configuration compile
The command result will show you human-readable tree hierarchy of all dependencies as below.
compile - Classpath for compiling the main sources.
+--- org.androidannotations:androidannotations-api:3.2
+--- com.android.support:support-annotations:22.1.1
+--- com.squareup:otto:1.3.6
+--- in.srain.cube:grid-view-with-header-footer:1.0.10
+--- com.nostra13.universalimageloader:universal-image-loader:1.9.3
+--- com.github.chrisbanes.photoview:library:1.2.3
+--- org.simpleframework:simple-xml:2.7.1
+--- com.google.android.gms:play-services-base:6.5.+ -> 6.5.87
+--- project :yourProject
| +--- com.loopj.android:android-async-http:1.4.6
| +--- org.apache.httpcomponents:httpmime:4.2.5
| | \--- org.apache.httpcomponents:httpcore:4.2.4
| \--- com.google.code.gson:gson:2.3.1
+--- project :facebook
| \--- com.android.support:appcompat-v7:22.1.1
| \--- com.android.support:support-v4:22.1.1
| \--- com.android.support:support-annotations:22.1.1 -> 22.2.0
You can see overriden dependencies and decide in mind which ones should be avoided. In above example, last line com.android.support:support-annotations
presents overriden from 22.1.1
to 22.2.0
internally.
To avoid duplicates, you can add exclude
clauses in each project build.gradle
file.
compile('com.github.chrisbanes.photoview:library:1.2.3') {
exclude group: 'com.android.support'
}
compile('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile('com.google.android.gms:play-services-base:6.5.+') {
exclude module: 'support-v4'
}
For more information, you can see the tutorial at https://docs.gradle.org/current/userguide/userguide_single.html#sec:listing_dependencies
Gradle: How to check for duplicate dependencies in project?
You can use ./gradlew projectName:dependencies
to see a tree of all the dependencies of your project. Both that are repeated or with different versions are remarked in the different configurations and classpaths.
How to Remove Duplicate Libraries added via gradle?
Instead of adding it in the Configurations. I added the exclude for only the library like this:
compile ('com.rengwuxian.materialedittext:library:1.7.1') {
exclude group: 'com.nineoldandroids', module: 'library'
}
Resolve duplicated external libraries in Android Studio
This might be because of something called as Transitive dependency. Lets say you are using android core library version 1.5.0 and you are also using an another library say XyzImage library. Now the XyzImage library internally depends on the android core library version 1.2.0. Now due to this your app dependency tree would look like as follow:
-- Your App
+-> AndroidCore@1.5.0
+-> XyzImageLibrary@1.1.0
+-> AndroidCore@1.2.0
Now the XyzImageLibrary can configure it's gradle file in such a way that the gradle should only use the 1.2.0 version of the AndroidCore library while processing the XyzImageLibrary files. Due to this, gradle would need to download multiple version of same library. You can lookup the dependency tree of your Android App by following the solution https://stackoverflow.com/a/35235229/5309486 .
Android build.gradle Exclude duplicate classes
You can find all the dependencies of your project with the command
./gradlew :app:dependencies
Bitmovin and Purchasely seems to both use exoplayer.
So to avoid conflicts you can remove the module exoplayer from either one of those dependencies.
In your case, I think you should remove it from Purchasely
implementation ("io.purchasely:core:2.4.7") {
exclude module: 'exoplayer-core'
exclude module: 'exoplayer-hls'
exclude module: 'exoplayer-dash'
exclude module: 'exoplayer-ui'
exclude module: 'extension-okhttp'
exclude module: 'extension-mediasession'
}
Android Duplicate Dependencies
Seems you have included same library file twice
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'gson-*.jar')
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
So it seems that gson-*.jar
and Parse-*.jar
are included twice.
Edit:
As you said the problem is with umano sliding up library, then it should be the problem of its dependencies.
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:support-annotations:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.nineoldandroids:library:2.4.0'
}
And I have check com.baoyz.pullrefreshlayout:library
, it has the following dependency
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
}
so you included 2 versions of support library, and thus having the problem.
compile 'com.baoyz.pullrefreshlayout:library:1.0.1'
To fix the problem, replace the line above to the one below.
compile('com.baoyz.pullrefreshlayout:library:1.0.1') {
{
exclude group: 'com.android.support', module: 'support-v4'
}
In addition to the above, setup multidex following the guide below
https://developer.android.com/tools/building/multidex.html
Related Topics
Why I'm Getting Duplicate Class When Running My Android Project
Help with Passing Arraylist and Parcelable Activity
Highlight Text in Textview or Webview
Changing the Android Overflow Menu Icon Programmatically
Android Overriding Onbackpressed()
Service Not Available While Calling Geocoder.Getfromlocation()
Android Getdefaultsharedpreferences
Spannablestring with Image Example
Android Drawable Images from Url
About Android Image and Asset Sizes
Read Only File System on Android
How to View Androidmanifest.Xml from APK File
How to Set Textview Textstyle Such as Bold, Italic
React-Native: Command Not Found
Adb Not Responding - Wait More or Kill Adb or Restart (Ubuntu 13) 64-Bit
Retrieving All Drawable Resources from Resources Object