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

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'
}

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'

getting transformClassesWithJarMergingForRelease error in 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.

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'
}

Resources from appcompat-v7:22.2.0 giving error in Android Studio

I have added compile 'com.android.support:appcompat-v7:22.2.0' as dependency in build.gradle. But then also app giving error in accessing many resources from appcompat-v7.
Error:
Error:(25, 64) No resource found that matches the given name (at 'drawable' with value '#drawable/abc_textfield_default_mtrl_alpha').
please provide the detail error stack-trace
In Build.gradle add this in dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}

Android Studio (Gradle) cannot find Mockito

I try to use Mockito from within Android Studio 1.2.2 but I get the following error:
Error:(50, 17) Failed to resolve: org.mockito:mockito-core:1.10.19
The error occurs when I sync Gradle after adding the dependency manually. This is the dependency in my module Gradle file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
testCompile 'org.mockito:mockito-core:1.10.19'
}
Could anyone help my resolve this issue?
Related questions:
Do I first need to download Mockito manually?
If so, where should I put it?
Note: the comments were helpfull to solve the above problem. However, it got me into another problem which I could not solve. But updating to Android Studio 1.3 solved it. I am now running Mockito from within Android Studio.
Try replacing testCompile with androidTestCompile, it works for me when importing Mockito libs.
However, you may run to a runtime error if you include only mockito-core. You'll need to add into your gradle:
androidTestCompile "org.mockito:mockito-core:1.10.19"
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
If you have error with dexcache, put this line into your setUp() (Assuming you are using InstrumentalTestCase)
System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath());
I was stuck into a similar problem, and adding the mockito jar file manually did the thing for me.
To do that, first create a directory called "libs" in your app directory. Take note that this directory should be in the same level as that of the src/main and build directories.
Next, download the mockito jar file and paste it into the libs directory.
Include that into your dependencies in the app level build.gradle file:
dependencies {
compile files('libs/add-your-jar-file-name-here')
}
Sync the gradle and that should do the job.
Refer to this answer for more detailed answer with snapshots.
androidTestCompile has now been replaced with androidTestImplementation
dependencies {
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'org.mockito:mockito-core:1.10.19'
}
Make sure the test file is located under $your_module/src/test/java or $your_module/src/androidTest/java directory.

Resources