In my Android project after I add some libraries when I'm running it a exception arose. my build.gradle file is as below.
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.marpak.livefarmerpro"
minSdkVersion 14
targetSdkVersion 19
versionCode 69
versionName '2.0.15'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile project(':holoColorPickermaster')
compile project(':qRCodeReaderViewlib')
compile project(':volley')
compile project(':library')
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:multidex:'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
}
and when I running the app ir gives me following error.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/concurrent/BasicFuture.class
I know this is because some duplication of files. can someone help he to fix this issue. thanks and regards!
I got this issue when I had 2 classes with the same class name. Doing ./gradlew app:assembleDebug --stacktrace --debug --info said
java.util.zip.ZipException: duplicate entry: com/arka/commonlib/model/Charge.class
You can test putting this on root of directory in the Terminal
./gradlew clean
for more detail visit this : Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'
Related
Hey guys I'm using android studio 3.0.1 and I have a problem when running my project ever since i added a maven dependency.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.jake.myapplication"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:+'
}
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v2.2.4'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.github.pabloo99.xmlsoccer:xmlsoccer:0.0.6'
}
when i now run this i get the error: Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
More than one file was found with OS independent path 'org/springframework/web/servlet/config/spring-mvc-3.0.xsd'
I have looked around elsewhere on stackoverflow and have found solutions but the people dont seem to have the org/springframework error. I have tried deleting the .gradle file and cleaning and building, however when i rebuild the project i get the error: Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
which i thought would have been solved with: multiDexEnabled true
any ideas on how to get this working? if you need more information please let me know. I am very new to this. Thank you so much in advance.
Hi i am trying to build APK but i Fetching this problem in Android Studio.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/INetworkTaskCallback$Stub.class
Gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.mouad.fixmyphone"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
The documentation for Firebase JobDispatcher says to include only one of these:
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
You are including both. Because your app does not have a dependency on com.google.android.gms:play-services-gcm, you should only include this library:
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
Remove this line from your dependencies:
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
After many attempts to use others network solutions , I feel despair .
I wil be more then happy if someone could help me with this Problem!:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_65\bin\java.exe'' finished with non-zero exit value 3
My project run perfectly until I tried to add new dependencies to my project
org.apache.pdfbox:pdfbox:1.5.0,
com.github.PhilJay:MPAndroidChart:v2.2.3 or 'com.google.guava:guava:16.0.1'- but withot success - Always get the same error.
Each one I also tried to added in diffrent ways: as Module, Jar or Gradle dependencie of course - Always get the same error.
My Gradle Version: 'com.android.tools.build:gradle:1.5.0'
Android Studio: 1.5.1
SDK: 23
This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.alfred.alfredapplication"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services-identity:7.8.0'
compile('com.google.api-client:google-api-client-android:1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-gmail:v1-rev40-1.21.0') {
exclude group: 'org.apache.httpcomponents'
}
/*compile files('libs/pdfbox-2.0.0.jar')*/
compile 'com.android.support:multidex:1.0.1'
My AndroidManifest.xml include :
android:name="android.support.multidex.MultiDexApplication
So what's the problem could be? Thanks a lot!
Add these lines under android { } in gradle file.
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
}
Am getting an unexpected error in Android studio while running the app,following is the error message which am getting
Error:duplicate files during packaging of APK
/home/jithu/libs/android/android/aa/app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: META-INF/DEPENDENCIES Origin 1:
/home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.6/cf8bacbf0d476c7f2221f861269365b66447f7ec/httpmime-4.3.6.jar
Origin 2:
/home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.1/f5aa318bda4c6c8d688c9d00b90681dcd82ce636/httpcore-4.4.1.jar
Am pasting my build.gradle file also
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.google.code.gson:gson:2.2.4'
compile "org.apache.httpcomponents:httpcore:4.4.1"
compile "org.apache.httpcomponents:httpmime:4.3.6"
}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
// ...
}
Well you are missing the flow of build gradle.
As you are trying to use 2 android {..} snippet it is not detecting the 2nd one. As a result your exclusion of duplicate meta files are not working.
Possible solution:
Just change the order of your build gradle like below:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.google.code.gson:gson:2.2.4'
compile "org.apache.httpcomponents:httpcore:4.4.1"
compile "org.apache.httpcomponents:httpmime:4.3.6"
}
If it still didn't work then check out the following:
Is it your library build gradle?
I excluded my duplicate meta files from my main projects build gradle. So make sure to exclude the meta files from build gradle of app module rather than library module.
I installed Android Studio version 1.0.1 and tried to import my project from eclipse to it it gave me the following error:
Error:Execution failed for task ':app:packageDebug'.
Duplicate files copied in APK META-INF/DEPENDENCIES
File 1: E:\app3\app\libs\httpmime-4.3.jar
File 2: E:\app3\app\libs\httpmime-4.3.jar``
I've tried to import my project with both using converting jars option to gradle and without converting them
i've searched a lot and tried solutions online but also didn't work
here is my build.gradle for my project
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.FluoraPin.androidApp"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
android {
packagingOptions {
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile project(':beyondAR_Framework')
compile project(':facebookSDK')
compile project(':volley')
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/commons-logging-1.1.3.jar')
compile files('libs/httpclient-4.3.6.jar')
compile files('libs/httpclient-cache-4.3.6.jar')
compile files('libs/httpcore-4.3.3.jar')
compile files('libs/httpmime-4.3.jar')
compile files('libs/picasso-2.3.4.jar')
compile files('libs/retrofit-1.8.0.jar')
}
adding
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
should solve your problem.
you have duplication in dependencies:
compile files('libs/httpclient-4.3.6.jar')
compile files('libs/httpclient-cache-4.3.6.jar')
class files in these 2 are the same