2016-03-27 67 views
0

我使用YouTube SDK在viewpager中播放视频。只要我运行该应用程序,就会引发此错误: 错误:执行任务':app:transformClassesWithJarMergingForDebug'失败。错误:使用YouTube API时,执行任务':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:[email protected]' 
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:[email protected]') { 
    transitive = true 
} 
compile files('libs/YouTubeAndroidPlayerApi.jar') 
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:[email protected]' 
} 

我不能包括

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

为viewpager使用支持库V4

回答

0

该错误来当你的任何JAR依赖的有同班。确保你没有添加支持jar作为gradle和jar依赖。可能有重复的引用到同一个API。

从命令行尝试./gradlew yourBuildVariantName --debug。您可以安全地从项目或构建文件中删除它,使用命令./gradlew clean进行清理并重建项目(如果需要,重复)。

检查这个相关的问题Gradle Duplicate Entry: java.util.zip.ZipExceptionjava.util.zip.ZipException: duplicate entry during packageAllDebugClassesForMultiDex

0

我观察过Android Studio后同样的问题升级到版本2.2预览6条

然后我删除线:从两个

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

flatDir { dirs 'libs'}

build.grad le文件并且问题没有了。

看起来'libs'目录是自动生成的,但我无法在Google页面上找到任何确认。

0

中的build.gradle文件中添加

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

相关问题