I have used multiple Android libraries and modules in my project. Each one has its own v4.Support lib. I am getting java.util.zip.ZipException: duplicate entry
As I workaround my above problem and find a way to overcome it. Main reason for packageAllDebugClassesForMultiDex error is the same you find in all other posts in Stackoverflow i.e. you must have some class files which are available more than once in project. In my case I have so many modules in above project as Facebook , google pay services and sliding menu etc.. . All these module have there own copy of v4.support jar file. What I did was delete all v4.support files from all these libraries libs folder. Then Add dependency to v4.support lib from my sdks i.e. com.android.support libs from Android Studio project Structure. For This..
2* Select each one of these modules one by one.
3* In the last tab named Dependency , Remove compile fileTree(dir: 'libs', include: '*.jar') if you had only v4.support lib (or the probleomatic one)in libs folder of that module.
4* Add v4.support lib by clicking + then add libraries and select v4.support libs from your sdks.
Its done. Clean the project and build it again.packageAllDebugClassesForMultiDex problem has gone.
As for transitive dependency , if you know the exact dependency which cause the Duplicate file in dex error while building the project, you can exclude it as belo
 compile(project(':..:..:..:..:..:..:android_libraries:walletsdkandroidmodule')) {
        exclude group: 'com.google.code.gson'
    }
If you want any transitive dependency in any module, eg.
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
        transitive = true
    }