I updated my android studio from 1.5 version to current latest v2.1.1 and also updated build tools version to 2.1.0 and gradle distributionUrl to https://services.gradle.org/distributions/gradle-2.10-all.zip
After updating this changes, I am able to run the application on device but when I try to code sign the application getting this error -
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
Here's look at my build.gradle file -
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')
}
And My application class is extending MultiDexApplication class instance.
I have even updated my buildToolsVersion to "23.0.3" from "23.0.1" but still getting the same above error.
It will be really helpful if someone can point out what is broken?
So it finally turns out that PartSource.class was present in org.apache.http.legacy.jar. And org.apache.http.legacy.jar was added as a dependency in one of the library project and also in project's dependency. It was resolved by commenting out the org.apache.http.legacy.jar dependency in project's gradle.
Still I have no clue as to why it was working on older android studio version and why it is working if i run/debug the app. But still, problem is resolved now