更新 Android Studio 后签名失败

Signing failed after updating Android Studio

我将我的 android 工作室从 1.5 版本更新到当前最新的 v2.1.1,还将构建工具版本更新到 2.1.0,并将 gradle distributionUrl 更新到 https://services.gradle .org/distributions/gradle-2.10-all.zip

更新此更改后,我能够 运行 设备上的应用程序但是当我尝试对应用程序进行代码签名时出现此错误 -

Error:Execution failed for task ':projectName:transformClassesWithJarMergingForRelease'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/android/internal/http/multipart/PartSource.class

看一下我的build.gradle文件-

apply plugin: 'com.android.application'

android {
   signingConfigs {
    config {
        keyAlias 'aliasname'
        keyPassword ''
        storeFile file('/opt/keystorename.keystore')
        storePassword ''
    }
   }
   compileSdkVersion 23
   buildToolsVersion "23.0.3"
   defaultConfig {
    applicationId "com.companyname.project"
    minSdkVersion 9
    targetSdkVersion 23
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    multiDexEnabled true
}
dexOptions{
    incremental true
}

  buildTypes {
    release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt')
         signingConfig signingConfigs.config
         zipAlignEnabled true
     }
 }
}

dependencies {
  compile project(':libraryInfiniteScrollListView')
  compile project(':libraryPagerSlidingTabStrip')
  compile project(':libraryParallaxScroll')
  compile project(':library_CardView_Supportv7')
  compile(project(':librarySwipeListView'))

  compile 'com.google.android.gms:play-services-base:8.4.0'
  compile 'com.google.android.gms:play-services-plus:8.4.0'
  compile 'com.google.android.gms:play-services-location:8.4.0'
  compile 'com.google.android.gms:play-services-gcm:8.4.0'
  compile 'com.android.support:appcompat-v7:23.4.0'
  compile files('libs/AndroidEasingFunctions-1.0.0.jar')
  compile files('libs/AndroidViewAnimations-1.0.6.jar')
  compile files('libs/calligraphy-1.1.0.jar')
  compile files('libs/flexjson-2.1.jar')
  compile files('libs/libBeaconService.jar')
  compile files('libs/libraryhttploopj.jar')
  compile files('libs/localytics.jar')
  compile 'com.nineoldandroids:library:2.4.0'
  compile files('libs/universal-image-loader-1.9.3.jar')
  compile files('libs/YouTubeAndroidPlayerApi.jar')
  compile 'com.android.support:multidex:1.0.1'
  // org.apache.http package is deprecated and removed in 23 sdk version and above
  compile files('libs/org.apache.http.legacy.jar')
}

我的应用程序 class 正在扩展 MultiDexApplication class 实例。

我什至已将我的 buildToolsVersion 从“23.0.1”更新为“23.0.3”,但仍然出现上述相同的错误。

如果有人能指出什么地方坏了,那真的很有帮助吗?

所以最后证明 PartSource.class 出现在 org.apache.http.legacy.jar 中。并且 org.apache.http.legacy.jar 作为依赖项添加到库项目之一以及项目的依赖项中。通过在项目的 gradle.

中注释掉 org.apache.http.legacy.jar 依赖项解决了这个问题

我仍然不知道为什么它在旧的 android 工作室版本上工作,以及为什么它在我 run/debug 应用程序时工作。不过问题还是解决了