android - 如何解决java.util.zip.ZipException duplicate entry : com/google/gson/annotations/Expose.类?

标签 android android-studio android-gradle-plugin build.gradle

我已经使用 fabrik 插件实现了 Twitter 登录,在设置 Twitter 集成后我遇到了这个问题,有人可以告诉我这有什么问题吗?我已经粘贴了我的 gradle 和 logcat。

渐变代码

buildscript {
      repositories {
      maven { url 'https://maven.fabric.io/public' }
           }

      dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
               }
           }
      apply plugin: 'com.android.application'


    repositories {
        maven { url 'https://maven.fabric.io/public' }
            }


           android {
          compileSdkVersion 23
          buildToolsVersion "23.0.3"

         defaultConfig {
            applicationId "com.matrix_intech.manabitas"
            minSdkVersion 15
             targetSdkVersion 23
           versionCode 1
            versionName "1.0"
            multiDexEnabled true

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

          sourceSets.main {
            jniLibs.srcDir 'libs'
              jni.srcDirs = [] //disable automatic ndk-build call
              }



          dexOptions {
              javaMaxHeapSize "4g"
            }

             }

            dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      compile 'com.android.support:appcompat-v7:23.0.0'
      compile files('libs/gson-2.3.1.jar')
      compile files('libs/volley.jar')
      compile files('libs/async.jar')
      compile files('libs/async_loopj.jar')
      compile 'com.squareup.picasso:picasso:2.5.2'
      compile 'com.google.firebase:firebase-messaging:9.2.1'
      compile 'com.google.android.gms:play-services:9.2.1'
      compile 'com.android.support:multidex:1.0.0'
      compile 'io.github.rockerhieu:emojicon:1.4.0'

    //for video compression
    //refer this url [https://github.com/lalongooo/VideoCompressor]
    compile files('libs/aspectjrt-1.7.3 (1).jar')
    compile files('libs/isoparser-1.0.6.jar')

    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    compile('com.twitter.sdk.android:twitter:2.1.1@aar') {
    transitive = true;

     }
     }

    apply plugin: 'com.google.gms.google-services'
    apply plugin: 'io.fabric'

逻辑猫

        Information:Gradle tasks [:app:assembleDebug]
        Warning:string 'telephone' has no default translation.
        Error:Execution failed for task   
       ':app:transformClassesWithJarMergingForDebug'.
       > com.android.build.api.transform.TransformException:  
       java.util.zip.ZipException: duplicate entry: 
       com/google/gson/annotations/Expose.class
        Information:BUILD FAILED

        Information:Total time: 3.682 secs
        Information:1 error
        Information:1 warning
        Information:See complete output in console

最佳答案

你应该从 twitter dependency排除模块:'gson'

 compile('com.twitter.sdk.android:twitter:1.10.0@aar') {
    transitive = true;
    exclude module: 'gson'
}

您已经将 GSON 添加为 gson-2.3.1.jar

关于android - 如何解决java.util.zip.ZipException duplicate entry : com/google/gson/annotations/Expose.类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40240414/

相关文章:

android-studio - JAVA_HOME 设置为无效目录 A​​ndroid Studio Flutter

android - Red5Pro调试Android Studio异常

android - 检查 AAR 元数据值时发现一个或多个问题 :

Android - 将所有 lint 警告设置为错误,某些警告除外

android - 如何解决转换为 Dalvik 格式失败的错误?

java - Java 中捕获和抛出 NullPointerException

android - 尝试在 Gingerbread 设备上运行时出现 INSTALL_FAILED_OLDER_SDK

android - 如何安装存储库 com.android.support :appcompat-v7

PhoneGap/DreamWeaver CS6 找不到 Android SDK

android - ScheduledExecutorService 未启动