Jar merging for debug throwing duplicate entry with android? - java

Im getting this error when trying to run my build:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/AnimatorRes.class
Here is my build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile('com.digits.sdk.android:digits:1.9.0#aar') {
transitive = true;
}
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'me.zhanghai.android.materialprogressbar:library:1.0.2'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.anjlab.android.iab.v3:library:1.0.+#aar'
}
Here is a pic of my libs
Im hoping someone here can help me find out what the issue is. Im using android studio.

Try excluding the support-v4 since the google-play-services already contains the support-v4
compile ('com.google.android.gms:play-services:8.1.0')
{
exclude group: 'com.android.support', module: 'support-v4'
}
if it doesn't work,
Clean the project and rebuild it.
Else, try setting multiDexEnabled in the gradle file
defaultConfig {
multiDexEnabled true
}

Related

No static method zzb - when user firebase-database and facebook account kit

when using facebook, firebase-database account kit alone both work fine but when I am using both in same time in a project it give error-
java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzac; or its super classes (declaration of 'com.google.android.gms.common.internal.zzac' appears in /data/app/com.neccargo-2/split_lib_dependencies_apk.apk:classes14.dex)
I am using 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.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:account-kit-sdk:4.+'
compile 'com.karumi:dexter:4.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1#aar'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.jakewharton:butterknife:8.7.0'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
}
apply plugin: 'com.google.gms.google-services'
I am stuck about to find solution.
Try adding firebase core library.
compile 'com.google.firebase:firebase-core:10.0.1'
I find my solution after many failure. In dependencies use those -
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:11.0.1'
and then add multiDexEnabled true in build.gradle
then add those line in buildscript-
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.google.firebase:firebase-plugins:1.0.4'
in there also add in allprojects-
maven {
url "https://maven.google.com"
}
Then create a class like -
public class AppUtils extends Application {
#Override
public void onCreate() {
super.onCreate();
FirebaseApp.initializeApp(getApplicationContext());
}
}
add this class name in AndroidManifest like-
android:name=".AppUtils"
That's the process I overcome that problem.

Adding Facebook SDK to android studio project using Gradle. Manifest merger failed error coming. Multiple support libraries conflict. What to do?

My app.gradle file contains :-
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.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
testCompile 'junit:junit:4.12'
}
Gradle console error output
What went wrong:
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.
You have to use latest Facebook SDK.
You should use this.
compile 'com.facebook.android:facebook-android-sdk:4.25.0'
Then clean and rebuild the project.
Hope it helps.

How to exclude a class from jar in Android Studio

I'm trying to exclude a class from jar, but it doesn't work.
Let me know hot to do it.
This is my code:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.google.android.gms:play-services-gcm:8.3.0') {
exclude module: 'com.google.android.gms.iid/zzb'
}
compile 'org.xwalk:xwalk_core_library:14.43.343.17'
compile 'com.google.code.gson:gson:2.4'
compile 'commons-io:commons-io:2.4'
compile 'com.google.android.gms:play-services-analytics:10.2.1'
compile project(":adjust")
}
This is the error message:
Error:Execution failed for task ':app:packageAllReleaseClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/iid/zzb$zza$zza.class
In plain Gradle, what you are looking for can be achieved as:
dependencies {
compile('com.example.m:m:1.0') {
exclude group: 'org.unwanted', module: 'x
}
compile 'com.example.l:1.0'
}
This would exclude the module X from the dependencies of M, but will still bring it if you depend on L.

duplicate entry: com/google/android/gms/measurement/AppMeasurementContentProvider.class

This error started appearing after I updated firebase SDK on my project. If i try to build the project normally its working fine. but whenever trying to build a signed APK its giving the following error.
Error:Execution failed for task
':app:transformClassesWithJarMergingForProductionRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/android/gms/measurement/AppMeasurementContentProvider.class
here are my project dependencies. not sure where the duplication is occurring.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile(name: 'google-maps-sdk-m4b', ext: 'aar')
compile('io.intercom.android:intercom-sdk:1.+#aar') { transitive = true }
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile 'com.google.maps.android:android-maps-utils:0.4.1'
compile 'com.stripe:stripe-android:+'
compile 'com.github.jkwiecien:EasyImage:1.2.1'
compile 'com.github.dbachelder:CreditCardEntry:1.4.7'
compile 'com.appsflyer:af-android-sdk:4.3.5#aar'
compile 'com.bugsnag:bugsnag-android:+'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.google.firebase:firebase-database:9.0.2'
compile 'com.google.firebase:firebase-auth:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'cn.aigestudio.wheelpicker:WheelPicker:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
I have solved by changing
classpath 'com.google.gms:google-services:2.0.0-alpha2'
To
classpath 'com.google.gms:google-services:3.0.0'
In project level gradle file
So I figured solution to the problem. Adding exclude group: 'com.google.android.gms' solved the issue:
compile('io.intercom.android:intercom-sdk:1.+#aar') {
transitive = true
exclude group: 'com.google.android.gms'
}

Gradle error after including facebook sdk

Immediately after adding the facebook-audience-network-sdk in my gradle file, I started getting errors, the first one I fixed my adding multiDexEnabled true, after that I keep getting this error
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqa.class
Here are my dependencies list in build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.17'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
compile 'com.facebook.android:audience-network-sdk:4.10.0'
compile 'joda-time:joda-time:2.7'
}
After running gradle with -q dependencies here is my screenshot, I think the problem is related to google play services libraries seeing the facebook.android:audience-network-sdk depends on analytics 7.8.0 while I have included the latest 8.4.0 already in my dependencies, I'm not sure.
How can i fix this?
I finally got rid of the error. So the problem was with the com.google.android.gms:play-services-ads-8.1.0. You can see from the image it was 8.1.0 and other play dependencies were 8.4.0.
So these two ways worked. One was to change the dependency into
compile ('com.facebook.android:facebook-android-sdk:4.10.0'){
exclude group:"com.google.android.gms"
}
But the issue with this is that, it could be a problem since in my other dependencies I didn't have play-services-ads:8.4.0'
So the way I solved this was just add a single line
compile 'com.google.android.gms:play-services-ads:8.4.0'
This way everything worked perfectly, because when gradle compiled it automatically replaced the 8.1.0 into the 8.4.0
Here is my final dependencies list that worked
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.17'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
compile 'com.facebook.android:audience-network-sdk:4.10.0'
compile 'joda-time:joda-time:2.7'
}

Categories