API集成到android应用中时出现com

API集成到android应用中时出现com

本文介绍了尝试将Youtube Data API集成到android应用中时出现com.android.dex.DexException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将Youtube DATA Api功能集成到我的应用程序中时,我终于设法解决了所有错误.但是当我运行该项目时,它给了我以下错误:

When I try to integrate Youtube DATA Api functionality into my app, I finally managed to resolve all errors. But when I run the project, it gives me the following error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/api/client/auth/oauth/AbstractOAuthGetToken;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)

我的build.gradle文件如下:

My build.gradle file is as follows:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "wheresapp.iiitb.com.wheresapp"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}


buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),   'proguard-rules.pro'
    }
}
}

dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.apis:google-api-services-youtube:v3-rev152-1.21.0'
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/api-1.3.jar')
compile files('libs/json-simple.jar')
compile files('libs/google-oauth-client-1.16.0-rc.jar')
compile files('libs/google-oauth-client-jetty-1.11.0-beta.jar')
compile files('libs/google-oauth-client-java6-1.11.0-beta.jar')
}

我在这里查看了很多示例,但无法解决此错误.如果我设置

I have looked at so many examples here but I am unable to resolve this error. If I set

multidexenabled true

在Gradle文件中,此错误消失了,但我又遇到了另一个错误

In the Gradle file this error vanishes but I get another error

java.util.zip.ZipException: duplicate entry: com/google/api/client/auth/oauth/package-info.class

推荐答案

dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.apis:google-api-services-youtube:v3-rev152-1.21.0'
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/api-1.3.jar')
compile files('libs/json-simple.jar')
compile files('libs/google-oauth-client-1.16.0-rc.jar')
compile files('libs/google-oauth-client-jetty-1.11.0-beta.jar')
compile files('libs/google-oauth-client-java6-1.11.0-beta.jar')
}

它应该以这种方式工作,并且您不需要

It should work in this way and you won't need the

multidexenabled true

了.

这篇关于尝试将Youtube Data API集成到android应用中时出现com.android.dex.DexException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 04:50