15

I am using external libraries payu money sdk and linkedin-sdk, both uses volley libraries, which while compiling project gives duplicate entry of AuthFailureError.class

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: com/android/volley/AuthFailureError.class"

i have also added following code to exclude module, but still same error

configurations{ all*.exclude module: 'com.android.volley' }

please help

  • due to this I guess http://stackoverflow.com/a/28937822/2032561 – Bharatesh Jun 21 '16 at 13:36
  • @Ankur did you got the solution for this problem? please reply ASAP. – Pankaj Arora Sep 23 '16 at 10:52
  • @Dev...yes after so much of trouble..i did that with excluding support-v4 library `compile('com.android.support:appcompat-v7:23.2.1') { exclude module: 'support-v4' } compile('com.google.android.gms:play-services:8.3.0') { exclude module: 'support-v4' }`, if it doesn't work let me know which libraries are creating problem. – Ankur Khandelwal Sep 24 '16 at 14:05
  • I have the same problem, could you please tell me how could i solve the problem? – Muhammad Azim Jan 02 '18 at 05:35

9 Answers9

12

I stumbled upon this same error, and after reading this, I was able to solve it.

Try adding this line inside your app dir build.gradle file -

android{
configurations {
    all*.exclude group: 'com.android.volley'
}}

Hope this helps.

Community
  • 1
  • 1
hsm59
  • 1,991
  • 19
  • 25
4

I had this problem when I tried to generate the APK (release) and I solved it changing the linkedin-sdk build.gradle:

From:

dependencies {
    compile 'com.android.support:support-annotations:20.0.0'
    compile 'com.android.support:support-v4:21.0.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/volley.jar')
    androidTestCompile('junit:junit:4.12') }

To:

dependencies {
    compile 'com.android.support:support-annotations:20.0.0'
    compile 'com.android.support:support-v4:21.0.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.volley:volley:1.0.0'
    androidTestCompile('junit:junit:4.12') }
giopromolla
  • 519
  • 5
  • 14
3

Add multiDexEnabled true in the defaultConfig section of your gradle file

Then,

compile 'com.android.support:multidex:1.0.1' in your dependencies

Finally add below in your application class:

 @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

Also, check if you are using volley.jar in your libs folder. If so, delete that jar file, and compile again. Sometimes, jar dependencies conflicts with those compiled using remote source.

asdec90
  • 1,070
  • 2
  • 13
  • 28
  • but if i remove that jar file from libs folder, my code won't run, it gives error that can't find volley – Ankur Khandelwal May 10 '16 at 11:51
  • Try "exclude group com.google.volley" module in the dependencies that use Volley in them. – asdec90 May 10 '16 at 13:15
  • still same error..i have use this `compile ('com.mcxiaoke.volley:library:1.0.18'){ exclude group: 'com.google.volley' }` in both libraries which uses volley library....also with using CMD+O it shows that AuthFailure class belongs to 'com.android.volley' group, after changing com.google.volley to com.android.volley..still not worked – Ankur Khandelwal May 11 '16 at 06:17
2

This is an example how to exclude classes in dependencies when there is duplicate entry in gradle.

 compile ('com.google.api-client:google-api-client-android:1.17.0-rc') {
    exclude module: 'httpclient'
 }

or try with your way just add some more text

configurations {
     all*.exclude group: 'com.android.support', module: 'support-v4'
}

So, now what you have to do is

Search CTRL+SHIFT+N in android studio for the class AuthFailureError.class See which jar contains this and remove it like above (This is just as an example/You have to figure out the duplicate class and manually remove it)

siddhesh
  • 563
  • 1
  • 9
  • 15
  • still same error for `configurations{ all*.exclude group: 'com.android.volley', module: 'library-1.0.18' }` also when i added exclude module to my build.gradle, it gives error 'Gradle DSL method not found: 'exclude()'' – Ankur Khandelwal May 10 '16 at 08:51
2

just remove the duplicate jar file(note:use new version,delete old version) for importing "com.android.volley.AuthFailureError" in build.gradle. Then clean project and rebuild project and then run you will get result.

vimal raj
  • 295
  • 1
  • 13
1

I had the similar issue while making build on Jenkins, weirdly it was working fine on my local machine. After adding below exclude it worked both on local machine and Jenkins.

android{
configurations {
    all*.exclude group: 'com.android.volley'
}}

I have added configurations block to my app's build.gradle inside android section.

If it matter's Compile SDK version is 22 and Build Tools version is 25.0.0

This worked like a charm.

Shyam Sunder
  • 523
  • 4
  • 13
0

Okay I got my answer

On mac instead of control n, it is command 0 and the command i needed was

configurations { all*.exclude module: 'volley-release' }

Adam Katz
  • 6,999
  • 11
  • 42
  • 74
0

Just remove your volley library from dependancy. Try clean and rebuild project it works for me. Ex. payusdk are also implementing volley library so that is the reason exception shows duplicate entry. I hope it works. because i also found this error and i do these things it works. Thanks.

Akhil
  • 61
  • 6
0

Use the below command in Android studio terminal to get the dependency conflict data - [Replace with your app Name]

./gradlew -q :<app>:dependencyInsight --dependency volley --configuration compile

If you are using latest Volley library from android [https://github.com/google/volley/releases], add below two lines in your build.gradle file under each of the compile library entries that has conflict.

Ex:

compile('com.xyz:abc:1.1.0-RELEASE') {
        exclude module: 'library'
        exclude group: 'com.mcxiaoke.volley'
}
Rams_QA
  • 121
  • 7