17

I integrated the Zendesk mobile sdk through its maven repository into my project and it wouldn't build anymore. It has some kind of a clash with picasso library that i am using. I get this error during the build:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/squareup/picasso/Action$RequestWeakReference.class 

I ran ../gradlew dependencies on the app folder and this is what i found under zendesk module:

\--- com.zendesk:sdk:1.0.0.1
     +--- com.squareup.retrofit:retrofit:1.4.1
     |    \--- com.google.code.gson:gson:2.2.4
     +--- com.squareup.picasso:picasso:2.3.2
     +--- com.android.support:support-v4:20.0.+ -> 21.0.3 (*)
     \--- com.android.support:appcompat-v7:20.0.+ -> 21.0.3 (*)

So zendesk is also using picasso but a different version than what i have in my project. I tried excluding picasso from zendesk like this:

compile (group: 'com.zendesk', name: 'sdk', version: '1.0.0.1'){
            exclude group: 'com.squareup.picasso'
        }

but this causes runtime exceptions in other components of the app. I get a NoDefFoundError for a class totally unrelated to the libraries.
Does any one have any idea how to get around this problem ?

Sayed Jalil Hassan
  • 2,535
  • 7
  • 30
  • 42

1 Answers1

27

When you added the com.android.support:multidex dependency you actually added some dependencies that collide with other dependencies.

I solved it by:
---------------
1. searching for the class, in you case the "RequestWeakReference.class" (in AndroidStudio just hit Ctrl+N on Windows or CMD-O on Mac)
2. See which jar contains it - Android Studio will write it in the popup.
3. Exclude it from all builds, for example:

android {
     configurations{
        all*.exclude module: 'servlet-api'
    }
}
Sheraz Ahmad Khilji
  • 8,300
  • 9
  • 52
  • 84
Tomer
  • 1,058
  • 11
  • 18
  • 8
    is there any right solution.i am getting same problem java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class please help me. i put like this configurations{ all*.exclude module: 'gson-2.1' } – RamBabu Pudari Jun 24 '15 at 10:27
  • @RamBabuPudari i am facing same issue with Expose.class. Have you find any solution? – Rohan Oct 05 '15 at 07:58
  • @Tomer This worked for me. I was facing similar issue when using volley in Android Studio in one of my projects. – Sheraz Ahmad Khilji Oct 12 '15 at 19:28
  • @SherazAhmadKhilji I am also facing the issue with Volley itself, Could you tell me what did you did exactly? – Pravinsingh Waghela Nov 20 '15 at 13:22
  • 1
    @PravinsinghWaghela i enabled multidex in my `build.gradle` and i played around with the gradle file until i got it to work. – Sheraz Ahmad Khilji Nov 23 '15 at 04:22
  • i m also facing same issue but i m only using add mobs in my app – Erum Jul 03 '16 at 18:48
  • @Rohan im in the same sh*t with the Expose.class. How did you manage, man? – LEMUEL ADANE Aug 12 '16 at 03:05
  • This is time saver solution. After 8 hours search end here. If this code not working just comment the conflict dependency. For ex: Dependency A in your library jar Comment/delete the Dependency A from your project – Ranjithkumar Sep 06 '17 at 12:14