在添加google play服务和osm jar android时获取dex文件的问题

时间:2015-08-05 10:21:40

标签: android google-play-services openstreetmap osmdroid

我在谷歌游戏商店实施osm应用程序,所以我添加了以下罐子。

当我运行我的项目时,我得到以下错误

Error Code:2

Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/api/client/googleapis/notifications/json/gson/GsonNotificationCallback;
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

apply plugin: 'com.android.application'

 android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.pkg.name"
    minSdkVersion 14
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),   'proguard-rules.pro'
    }
  }
 }

 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile project(':mapsForgeForOsmdroid')
compile project(':oSMBonusPack')
compile 'com.android.support:gridlayout-v7:22.2.0'
compile files('libs/picasso-2.5.2.jar')
compile 'com.google.api-client:google-api-client:1.20.0'
 compile 'com.google.api-client:google-api-client-android:1.20.0'
 compile 'com.google.api-client:google-api-client-gson:1.20.0'
 compile 'com.google.apis:google-api-services-calendar:v3-rev125-1.20.0'
compile 'com.google.android.gms:play-services:7.5.0'
/*    compile 'com.google.android.gms:play-services:7.5.0'
compile files('libs/google-api-client-appengine-1.20.0.jar')
compile files('libs/google-api-client-1.20.0 (2).jar')
compile files('libs/google-api-client-gson-1.19.0.jar')
compile files('libs/google-api-services-calendar-v3-rev133-1.20.0.jar')
compile files('libs/google-api-client-android-1.20.0 (1).jar')*/
   //compile files('libs/google-api-client-util-1.2.1-alpha.jar')
}

1 个答案:

答案 0 :(得分:0)

我认为OsmBonusPack带来了Gson的副本。尝试为其添加排除。

编辑: 您可以使用

找到有问题的库

gradle dependencies

一旦找到,您可以使用(举几个例子)将其排除

   compile('group:artifact:version') {  
     exclude module: 'cglib' //by artifact name 
     exclude group: 'org.jmock' //by group
     exclude group: 'org.unwanted', module: 'iAmBuggy' //by both name and group
}