android - 错误 :Execution failed for task ':app:packageAllDebugClassesForMultiDex'

标签 android gradle android-youtube-api android-multidex

当我尝试使用 YouTubeData API 构建应用程序时,出现“:app:packageAllDebugClassesForMultiDex”错误。我研究了其他几个涵盖此错误的线程,我得出的结论是我的构建文件中有库,这些库正在创建对构建文件的重复引用。我知道触发错误的文件是:

'com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class'



但是如何在不删除整个库的情况下从构建文件中排除引用?

这是我的构建文件
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "co.hannalupi.fitnessblenderapp"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.apis:google-api-services-youtube:v3-rev136-1.20.0'

}

这是我得到的错误:
    FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class

我是Android新手,您能指出我的任何方向将不胜感激。提前致谢。

最佳答案

有类似错误的人的更新 - 作为最后的手段,我从桌面上删除了我正在使用的项目文件,并从 GitHub 克隆了一个新副本。导入和运行新副本没有给我任何错误!!

关于android - 错误 :Execution failed for task ':app:packageAllDebugClassesForMultiDex' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30067105/

相关文章:

android - 如何在我的应用程序上自动播放 youtube 视频?

java - 在 Android 设备上查找 netMask

android - 如何为 Android TV 自定义选定的 RowPresenter

java - 如何对在 AndroidViewModel 类内部进行改造调用的方法进行单元测试?

android - 名称重复但维度不同的 Gradle 口味

gradle - gradle属性有时不起作用

c++ - 在WSL上安装Apache Kudu

java - 以编程方式创建 YouTubePlayerSupportFragment (Android)

android - 如何在Android中同步音频?

java - 如何从另一个 Activity 刷新 viewModel 实时数据