getting transformClassesWithJarMergingForRelease error in android studio - android-studio

I am getting error while creating sign apk in android studio.
Following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/HttpHeaders.class
My dependencies are following:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile project(':wordPayLib')
compile project(':simple-crop-image-lib')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.+'
compile 'com.crittercism:crittercism-android-agent:+'
compile 'com.google.android.gms:play-services:10.0.+'
compile 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-messaging:10.0.0'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.googlecode.android-query:android-query:0.24.3'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.skyfishjy.ripplebackground:library:1.0.1'
compile 'org.jsoup:jsoup:1.10.1'
compile 'com.squareup:otto:1.3.8'
compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
compile 'org.apache.httpcomponents:httpmime:4.3.5'
}
I am not using any external jar in libs folder.
Please suggest me how to fix above error.
Thank you.

Related

Using android volley showing error

When I am using android volley for inserting data into server database it is showing error cannot resolve the symbol R.
This is my dependencies in build.gradle(Module: app) where I just used a one line code
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.mcxiaoke.volley:library:1.0.19'}/*This line*/
and it is showing error after gradle running.
Cannot resolve the symbol R.
Include this compile 'com.android.volley:volley:1.0.0'.It should work.
try this
compile 'com.mcxiaoke.volley:library-aar:1.0.0'

failed to resolved:com.android.support:design:22.+

I installed android stadio bundle. but when I open it gives me this error
sdk manager
You can use
compile 'com.android.support:design:22.2.1'
Then Clean-Rebuild-Sync Your Project .
Edit
Rectify your SDK Path please .
Finally
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
}

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/CallSuper.class?

I tried all solutions available in stackoverflow. But none of them are working.
this is my dependencies in build.gradle file:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile ('com.android.support:appcompat-v7:23.1.1')
compile ('com.android.support:design:23.1.1')
compile ('com.google.android.gms:play-services:8.4.0')
compile files('libs/applovin-6.1.4.jar')
compile files('libs/appodeal-1.13.10.jar')
compile files('libs/chartboost-6.0.2.jar')
compile files('libs/inmobi-5.0.1.jar')
compile files('libs/my-target-4.1.2.jar')
compile files('libs/unity-ads-1.4.7.jar')
compile files('libs/yandex-metrica-android-2.00.jar')
compile ('com.android.support:multidex:1.0.1')
}
when I try to run I get this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/CallSuper.class
I have enabled multidex and included in manifest. I checked using ctrl+N, CallSuper is found in two jar files: 1) android.support.annotations and 2) support-v4.
Please help me out in eliminating this error. Thank You.
when we add
compile ('com.android.support:multidex:1.0.1') ,then something else will be added,so i solved my problem by changing
compile ('com.android.support:multidex:1.0.1')
to
androidTestCompile('com.android.support:multidex:1.0.1') {
exclude group: 'com.android.support', module: 'support-annotations'
}

Android Studio Build not working after migration from Eclipse

I'm migrating my Android project from Eclipse to Android Studio. The original project relied on two apache libraries: commons-io-2.4.jar and commons-codec-1.9.jar.
I've copied these jar files to the proper libs directory and updated build.gradle to reflect this:
dependencies {
compile project(':aviarySDK')
compile project(':showcaseView')
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/commons-cli-1.2.jar')
compile files('libs/httpclient-4.3.1.jar')
compile files('libs/httpcore-4.3.jar')
compile files('libs/httpmime-4.3.1.jar')
compile files('libs/metadata-extractor-2.6.4.jar')
compile files('libs/tape-1.1.0.jar')
compile files('libs/commons-codec-1.9.jar')
compile files('libs/commons-io-2.4.jar')
}
When I try to build the project a I get a duplication error message:
Error:duplicate files during packaging of APK /Users/gkipnis/repos/floomitandroidclient/floomItNewCamera/build/outputs/apk/floomItNewCamera-debug-unaligned.apk
Path in archive: META-INF/LICENSE.txt
Origin 1: /Users/gkipnis/repos/floomitandroidclient/floomItNewCamera/libs/commons-io-2.4.jar
Origin 2: /Users/gkipnis/repos/floomitandroidclient/floomItNewCamera/libs/commons-codec-1.9.jar
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
Error:Execution failed for task ':floomItNewCamera:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
File 1: /Users/gkipnis/repos/floomitandroidclient/floomItNewCamera/libs/commons-io-2.4.jar
File 2: /Users/gkipnis/repos/floomitandroidclient/floomItNewCamera/libs/commons-io-2.4.jar
Information:BUILD FAILED
Information:Total time: 3.144 secs
Can someone provide any pointers to what might be going on.
Thank You,
Gary Kipnis
As suggested by the error message add this part to your build.gradle
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}

cannot resolve symbol GoogleApiClient

in my application I was using LocationManager and now I want to use Fused Location Services
I'm using Android Studio 1.1.0 and added google play service library in gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':pull_to_refresh')
compile project(':uil_library')
compile project(':viewPagerIndicatorLib')
compile files('libs/date4j.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.google.maps.android:android-maps-utils:0.3.+'
compile 'joda-time:joda-time:2.7'
compile 'com.github.shell-software:fab:1.0.5'
compile 'com.google.android.gms:play-services:6.5.87'
}
but when I define GoogleApiClient variable it says
Cannot resolve symbol 'GoogleApiClient'
So I click alt+Enter to import it but it show 'Add library 'google-play-service-6.5.8.7' to classpath' so I click it and when I run my app it show error
Error:(9, 41) error: package com.google.android.gms.common.api does not exist
Error:(23, 13) error: cannot find symbol class GoogleApiClient
How can I solve this problem and what caused it in first place .
I feel very Stupid :)
this gradle was in my main app but I was using GoogleApiClient in Library project so I must add compile 'com.google.android.gms:play-services:6.5.87' to my library too

Resources