45860

Android Project Error Execution failed for task ':transformClassesWithJarMergingForDebug'

I was converting my android application from eclipse to Android Studio. When I built gradle there were no errors. But while running the application I got stuck with the following error:

Error:Execution failed for task ':transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/xmlpull/v1/XmlPullParserException.class

I tried to clean / rebuild project many times, but I always got the same error. I also tried Terminal command ./gradlew to clean it, but its not working.

Android Studio Version:2.1 Gradle Version: 2.1.2 jdk Version: 1.8 Android SDK Build-Tools: 24

build.gradle code:

apply plugin: 'com.android.application' dependencies { compile ('com.google.android.gms:play-services:9.0.2') compile 'com.android.support:appcompat-v7:24.0.0' compile files('libs/appcompat_v7.jar') compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar') compile files('libs/gcm.jar') compile files('libs/android.jar') compile files('libs/activation.jar') compile files('libs/additionnal.jar') compile ('com.google.android.gms:play-services-analytics:9.0.2') compile files('libs/libGoogleAnalyticsServices.jar') compile files('libs/mail.jar') compile "com.android.support:support-v4:24.0.0" compile "com.android.support:design:24.0.0" compile 'com.android.support:multidex:1.0.1' } buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' } } android { compileSdkVersion 23 buildToolsVersion "23.0.3" useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.expedite.apps.vedant" minSdkVersion 9 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } // Move the tests to tests/java, tests/res, etc... instrumentTest.setRoot('tests') // Move the build types to build-types/<type> // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of them default location under src/<type>/... which would // conflict with src/ being used by the main source set. // Adding new build types or product flavors should be accompanied // by a similar customization. debug.setRoot('build-types/debug') release.setRoot('build-types/release') } }

Answer1:

I solve my Error:

Following my build.gradle code:

apply plugin: 'com.android.application' dependencies { compile 'com.android.support:appcompat-v7:24.0.0' compile('com.google.android.gms:play-services:9.0.2') compile ('com.google.android.gms:play-services-analytics:9.0.2') compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar') compile "com.android.support:design:24.0.0" compile 'com.android.support:multidex:1.0.1' compile files('libs/mail.jar') compile files('libs/activation.jar') compile files('libs/gcm.jar') } buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' } } android { compileSdkVersion 23 buildToolsVersion "23.0.3" useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.expedite.apps.vedant" minSdkVersion 9 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } packagingOptions { exclude 'META-INF/NOTICE.txt' // will not include NOTICE file exclude 'META-INF/LICENSE.txt' // will not include LICENSE file exclude 'META-INF/LICENSE-FIREBASE.txt' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { javaMaxHeapSize "4g" } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } // Move the tests to tests/java, tests/res, etc... instrumentTest.setRoot('tests') // Move the build types to build-types/<type> // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of them default location under src/<type>/... which would // conflict with src/ being used by the main source set. // Adding new build types or product flavors should be accompanied // by a similar customization. debug.setRoot('build-types/debug') release.setRoot('build-types/release') } }

Add This one line in AndroidManifest.xml android:name="android.support.multidex.MultiDexApplication"

<application ..... android:name="android.support.multidex.MultiDexApplication"> </application>

Answer2:

<strong>Add Some Code in Your Build</strong>

I am adding some Lines like Package Option and Build Types...

apply plugin: 'com.android.application' dependencies { compile 'com.android.support:appcompat-v7:24.0.0' compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar') compile 'com.google.android.gms:play-services:+' compile files('libs/libGoogleAnalyticsServices.jar') compile "com.android.support:support-v4:24.0.0" compile "com.android.support:design:24.0.0" compile 'com.android.support:multidex:1.0.1' } buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' } } android { compileSdkVersion 23 buildToolsVersion "23.0.3" useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.expedite.apps.vedant" minSdkVersion 9 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true } packagingOptions { exclude 'META-INF/NOTICE.txt' // will not include NOTICE file exclude 'META-INF/LICENSE.txt' // will not include LICENSE file } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } // Move the tests to tests/java, tests/res, etc... instrumentTest.setRoot('tests') // Move the build types to build-types/<type> // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of them default location under src/<type>/... which would // conflict with src/ being used by the main source set. // Adding new build types or product flavors should be accompanied // by a similar customization. debug.setRoot('build-types/debug') release.setRoot('build-types/release') } }

Recommend

  • Cannot find androidTestCompile on Android build
  • Why cant I use Pattern.UNICODE_CHARACTER_CLASS in My Android App?
  • Android Calendar: first and last day of week -> zero month
  • ADT to Android Studio UNEXPECTED TOP-LEVEL EXCEPTION
  • android error while compiling com.android.support:support-v4:24.0.0
  • Entity Framework on SQL Server CE without driver install
  • Exception raised during Rendering: android.support.design.widget.CoordinatorLayout cannot be cast to
  • Google Analytics v4 in Android: Could not find class 'com.google.android.gms.analytics.Tracker&
  • What does the exclamation mark before class path do in ProGuard?
  • AdMob - Ad not displayed - Error 2
  • How can I speed up this row-by-row operation in data.table
  • Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.goog
  • In regards to the difference between Java “Properties” and C#' Properties
  • Xamarin Forms PopAsync crash
  • RTL language behavior in iOS 9
  • Found com.google.android.gms:play-services-places:9.2.1, but version 9.0.2 is needed for the google-
  • Android error - Failed to find style 'toolbarStyle' in current theme
  • Action Pack components in Rails
  • How to resolve this packager error on react native Android
  • AlertDialog style when using setView()
  • What is the difference between a “service account” and an “installed application”?
  • Request response issues in biztalk
  • cordova is not defined - cordova.js has already been loaded :: Ionic
  • Clear fused location provider's location for testing
  • Android Studio 1.3 RC3. Google Play services out of date. Requires 7571000 but found 6774470
  • Limiting recursion to certain level - Duplicate rows
  • azure media services - The request body is too large and exceeds the maximum permissible limit
  • Hardware Accelerated Image Scaling in windows using C++
  • Seeking advice on Jetty HttpClient Hang
  • Can I make an Android app that runs a web view in Chrome 39?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Adding custom controls to a full screen movie
  • Google cloud sdk not working when python points python3
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • How to include full .NET prerequisite for Wix Burn installer
  • using HTMLImports.whenReady not working in chrome
  • Busy indicator not showing up in wpf window [duplicate]
  • Android Heatmap on canvas or ImageView