duplicate entry android support v4 in serviceinfoversion impl.class - java

i have this error :
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl.class
on this build.gradle app :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.mtma.mytripmyadventure"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.android.support:support-v4:23.4.0') {
force = true;
}
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.roughike:bottom-bar:1.2.1'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.android.support:support-v4:23.4.0'
}
i have try many things to do but the result still the same
i have add all*.exclude group: 'com.android.support', module: 'support-v4'
but still error
help me to resolve this.. icant resolve it in 1 day
thx stackoverflow

I had a similar issue, I was importing
compile fr.avianey.com.viewpagerindicator:library:2.4.1.1'
and had to add "#aar" termination
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1#aar'

That error in your latest comment is completely different as it relates to an XML issue in your Activity.
You do not need the support-v4 dependency explicitly. It is included with the v7 dependency. That being said, definitely do not need to force = true on it
The solution to the first error is remove both dependencies of compile 'com.android.support:support-v4

This has worked for me.
compile('com.jakewharton:butterknife:8.5.1') {
exclude module: 'support-compat'
}

Related

Trying to build on Android

I am trying to build my app but i received this error. I have rebuilt, cleaned progect and reset Android Studio. This is the screenshot of the problem:
Code error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex 'C:\Users\User-1.gradle\caches\modules-2\files-2.1\stax\stax-api\1.0.1\49c100caf72d658aca8e58bd74a4ba90fa2b0d70\stax-api-1.0.1.jar' to 'C:\Users\User-1\Documents\workspace\WebUpHosting\app\build\intermediates\transforms\dex\debug\folders\1000\10\stax-api-1.0.1_4deeb811af0ea67608aa694ead937d7c9ac36202'
The problem is when i am building, because my app compiles right. Anyone knows how i could solve that?
UPDATE:
buil.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.webuphosting.app"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.daimajia.easing:library:2.0#aar'
compile 'com.daimajia.androidanimations:library:2.3#aar'
compile 'com.android.support:support-v4:26.+'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.android.support:recyclerview-v7:26.0.+'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile "com.squareup.retrofit2:converter-simplexml:2.3.0"
testCompile 'junit:junit:4.12'
}
Hard to tell the exact problem with more code to see, but as a solution, you could just simply disable pre-dex:
boolean preDexLibraries
Whether to pre-dex libraries. This can improve incremental builds, but clean builds may be slower.
To do so, add the following block in your main module (app)'s build.gradle file, inside the android:
android {
// everything else
dexOptions {
preDexLibraries = false
}
}
By default, it is set to true, so by setting it to false, you could get around your issue, but it may not solve the root-cause.

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

From the last few hours I'm trying to resolve this problem.
These errors came after updating the dependencies. The error I'm getting here is :
Execution failed for task app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
This is my build.gradle
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.lavazza"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
allprojects {
repositories {
mavenCentral()
}
}
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "2g"
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.3-alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Glide image library
//SUB-DEPENDENCIES
//Android-Iconics - used to provide an easy API for icons
compile files('libs/httpclient-4.5.3.jar')
compile files('libs/commons-codec-1.9.jar')
compile files('libs/commons-logging-1.2.jar')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.volley:volley:1.1.0-rc1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.android.support:multidex:1.0.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
compile 'com.google.android.gms:play-services:11.6.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.mikepenz:actionitembadge:3.3.1#aar'
compile 'com.mikepenz:iconics-core:2.8.1#aar'
compile 'com.github.rey5137:material:1.2.2'
compile 'com.android.support:mediarouter-v7:25.4.0'
testCompile 'junit:junit:4.12'
}
I've checked most of the SO answers for this issue, but nothing worked for me.
I've already tried the following:
1. clean and rebuild the project.
2. MultidexEnable is already true.
3. Invalidate cache and restart the Android studio.
Before marking it as a duplicate, please solve the issue for me.
I got stuck here.
I had similar issues and here is how I fixed it:
Check for upgrades to Android Studio and update to the latest version.
Add implementation 'com.android.support:design:27.1.0' to your app level build.gradle file.
Clean project and then rebuild.
Hope that helps!

Gradle build error after adding facebook dependency in Android Studio

I am creating an android app currently using firebase and facebook. I am trying to add a facebook login button, but when I add the line compile 'com.facebook.android:facebook-android-sdk:[4,5)' I get the error
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(26.0.0-alpha1) from [com.android.support:design:26.0.0-alpha1] AndroidManifest.xml:27:9-38
is also present at [com.android.support:cardview-v7:25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:25:5-27:41 to override.
when I try to sync the gradle build. Here is what my app build.gradle file looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26"
defaultConfig {
applicationId "com.notnow.barapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:support-v4:26.+'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
It's because Facebook library use com.android.support:cardview-v7:25.3.1 and you cannot use different support library with different version number. I resolved downgrading compileSdkVersion to 25 and all the support library to 25.3.1. You can check that Facebook library is using com.android.support:cardview-v7:25.3.1 at the following link: Facebook Core Gradle
Hope it helps.

Execution failed for transformClassesWithJarMergingForDebug'. (Volley)

I am trying to build my app on android studio virtual simulator, I have successfully tested on api level 21 and above now I am testing lower level api 19, but whenever I run i will get this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/android/volley/Request$Priority.class
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
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'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'dev.dworks.libs:volleyplus:0.1.4'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.android.support:design:25.1.0'
compile 'com.roughike:bottom-bar:1.2.1'
compile 'com.ncapdevi:frag-nav:1.2.2'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'net.gotev:uploadservice:3.0.3'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
compile 'com.hedgehog.ratingbar:app:1.1.2'
testCompile 'junit:junit:4.12'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
I have found many solution online regarding this but not specifically to this issue, I believe the problem is with volley, but I cannot remove any library due to my code. How should I solve this issue? Thank you!
You are using 2 different versions of volley libraries
compile 'com.android.volley:volley:1.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
use any one of the above
and I dont know about
compile 'dev.dworks.libs:volleyplus:0.1.4'
If that is similar library to above two ,the error will still remain

Could not find method exclude() for arguments [{module=support-v4}]

I am trying to run my application with instant run turned off but 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/v4/view/KeyEventCompatEclair.class
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.jua.app"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(path: ':app_Data')
compile files('libs/android-support-v4.jar')
}
I tried the solution from this thread:
compile files('libs/android-support-v4.jar'){
exclude module: "support-v4"
}
And now I am receiving this error when I try to Sync now gradle.build:
Error:(29, 0) Could not find method exclude() for arguments
[{module=support-v4}] on file collection of type
org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection.
Open File
I am a little lost right now, If anyone has any idea how to solve this I would appreciate it.
EDIT
I removed
compile files('libs/android-support-v4.jar')
completly and I still get the first error.
This is a syntax issue. The closure in which you are calling exclude is being interpreted as an argument to the files() method, which is incorrect. Should look like this
compile (files('libs/android-support-v4.jar')){
exclude module: "support-v4"
}
For anyone having the same problem, I deleted android-support-v4.jar from folder and now it works. For some reason, if you remove it from inside the gradle.build file it continues to create problems.

Categories

Resources