简体   繁体   中英

Paytab Payment gateway not working

I have to integrate paytabs payment gateway. After integrating their sdk module, the application not builds & app gets an error. My app gradle has below dependency.

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.android.gms:play-services:9.8.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.google.code.gson:gson:2.6.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.afollestad.material-dialogs:core:0.9.1.0'
    compile 'com.kyleduo.switchbutton:library:1.4.4'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile project(':PayTabs_SDK_SRC')
}

The Error looks like:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/Address.class

Update: If i remove below two dependency i don't get any error. But must have to use this retrofit dependence. Any Idea?

compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'

Look, PayTabs SDK includes com.squareup.okhttp3(version 3.5.0) and com.squareup.retrofit2:retrofit:2.2.0 uses okhttp3(version 3.6.0) which confused Gradle and generates a dexException(duplicate files exception).

To solve this problem you need to exclude one of okhttp3 version. Replace these below lines in build.gradle file.

compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'

With these lines of code:

compile ('com.squareup.retrofit2:retrofit:2.2.0'){
    exclude group: "com.squareup.okhttp3"
}
compile ('com.squareup.retrofit2:converter-gson:2.2.0'){
    exclude group: "com.squareup.okhttp3"
}

Hope it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM