1

I am trying to import eclipse project into android studio.After that adding my jar file i.e support jar into build gradle file whatever I have used in eclipse. While doing that getting below error.

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/database/DatabaseUtilsCompat.class 

and my build gradle file is:

apply plugin: 'com.android.application' configurations { // all*.exclude group: 'com.android.support', module: 'support-v4' // all*.exclude group: 'com.android.support', module: 'support-annotations' } android { compileSdkVersion 25 buildToolsVersion "26.0.0" useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.xxx.xxxxx" minSdkVersion 19 targetSdkVersion 25 multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } aaptOptions { cruncherEnabled = false } } dependencies { //compile 'com.android.support:appcompat-v7:25.2.0' compile 'com.google.android.gms:play-services:+' compile files('libs/android-query-full.0.26.7.jar') compile files('libs/commons-httpclient-3.0.1.jar') compile files('libs/glide-3.6.1.jar') compile files('libs/httpmime-4.1.3.jar') compile files('libs/library-1.2.1.jar') compile files('libs/mpandroidchartlibrary-2-2-4.jar') compile files('libs/picasso-2.4.0.jar') compile files('libs/android-support-v4.jar') compile files('libs/android-support-v7-appcompat.jar') compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') { exclude module: 'support-v4' // exclude duplicate library } } 
1
  • I was stuck here. Please help me Commented Oct 10, 2017 at 11:33

3 Answers 3

4

java.util.zip.ZipException: duplicate entry: android/support/v4/database/DatabaseUtilsCompat.class

Problem

  • exclude module: 'support-v4'

Don't

compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') { exclude module: 'support-v4' // exclude duplicate library } 

You Should Use

compile group: 'org.eclipse.paho', name: 'org.eclipse.paho.android.service', version: '1.0.2' 

If problem coming then add this in your build.gradle section

packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' } 

Then Clean-Rebuild-Run .

Sign up to request clarification or add additional context in comments.

8 Comments

@Durga add packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' }
@Durga within android { ...}
@Durga stackoverflow.com/questions/22467127/… . Hope this helps you .
@Durga Let me inform please .
I'm trying to resolve with ur link.. bt it's giving same.. any other mistake i did in my code???
|
0

Put below code below buildTypes and rebuild again project

 packagingOptions { exclude 'META-INF/NOTICE' // will not include NOTICE file exclude 'META-INF/LICENSE' // will not include LICENSE file exclude 'META-INF/DEPENDENCIES' // will not include LICENSE file exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } 

1 Comment

In build.gradle ...below buildTypes tag
0

Remove the line

compile files('libs/android-support-v4.jar') compile files('libs/android-support-v7-appcompat.jar') compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') { exclude module: 'support-v4' // exclude duplicate library } 

and add this line

compile 'com.android.support:appcompat-v7:25.4.0' compile 'com.android.support:support-v4:25.4.0' compile org.eclipse.paho:org.eclipse.paho.android.service:1.0.2 

Also add this inside the android{ }

repositories { mavenCentral() } 

For more information check this link https://www.eclipse.org/paho/clients/android/

2 Comments

I tried this.. not working.. give me any other solution
if i replace this giving another error .. install repository and sync project

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.