【问题标题】:Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' while using YouTube API错误:使用 YouTube API 时任务 ':app:transformClassesWithJarMergingForDebug' 执行失败
【发布时间】:2016-03-27 14:53:44
【问题描述】:

我正在使用 YouTube SDK 在浏览器中播放视频。一旦我运行该应用程序,就会引发此错误: 错误:任务 ':app:transformClassesWithJarMergingForDebug' 执行失败。

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目: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'
}

我不能包含

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

由于 viewpager 使用支持库 v4

【问题讨论】:

  • 你解决了吗?

标签: android youtube-api


【解决方案1】:

当您的任何 jar 依赖项具有相同的类时,就会出现该错误。确保您没有添加支持 jar 作为 gradle 和 jar 依赖项。可能有对同一 API 的重复引用。

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

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

【讨论】:

    【解决方案2】:

    我在 Android Studio 升级到版本 2.2 Preview 6

    后发现了同样的问题

    然后我删除了行:

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

    flatDir { dirs 'libs'}

    来自两个 build.gradle 文件,问题就消失了。

    看起来“libs”目录现在是自动构建的,但我无法在 Google 页面上找到任何确认信息。

    【讨论】:

      【解决方案3】:

      添加

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

      在 build.gradle 文件中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-09-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多