0

I'm using the YouTube SDK to play videos in a viewpager. As soon as I run the app, this error is thrown: Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/youtube/player/internal/u.class

Manifest.xml:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.xxxxx.www.xxx"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories {
mavenCentral()
mavenLocal()
maven { url "https://jitpack.io" }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.thefinestartist:ytpa:1.2.1'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar'
compile 'com.mxn.soul:flowingdrawer-core:1.2.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.13.0'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.xgc1986.android:parallaxpagertransformer:1.0.3'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7@aar') {
    transitive = true
}
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar'
}

I can't include

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

as viewpager uses support library v4

3 Answers3

0

That error comes when any of your jar dependency have same class. Make sure you have not added support jar both as gradle and jar dependency. There might be duplicate references to the same API.

Try ./gradlew yourBuildVariantName --debug from the command line. You can safely remove it from the project or from your build file(s), clean using the command ./gradlew clean and rebuild the project(repeat if necessary).

Check this related SO questions Gradle Duplicate Entry: java.util.zip.ZipException and java.util.zip.ZipException: duplicate entry during packageAllDebugClassesForMultiDex.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
0

I observed the same issue after Android Studio upgrade to version 2.2 Preview 6

Then I deleted lines:

compile(name: 'YouTubeAndroidPlayerApi', ext: 'jar')

and

flatDir { dirs 'libs'}

from two build.gradle files and the issue is gone.

Looks like 'libs' directory is built automatically now but I'm not able to find any confirmation on Google pages.

Alex P
  • 131
  • 1
  • 6
0

Add

dependencies {
compile 'com.android.support:support-v4:24.2.1' 
}

in build.gradle file.

volkangurbuz
  • 259
  • 1
  • 4
  • 14