Gradle error after including facebook sdk - java

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'
}

Related

Android bumping gradle support libraries from anything above 23.1.1 cause weird ui behaviour

I'm currently developing an app, which uses an old version of the android support libraries (current version is 27.0.1, my project has a combination of 23.1.1 and 23.0.1.
I tried along the years to update the version to the latest (really any version above the current), as well as aligning all the support libraries version, but when I do, my Recycler Views are starting to misbehave (weird spacing, crashes, etc...), screenshot comparisons:
Before:
After:
I have absolutely no idea how to fix it, any help will be greatly appreciated!
New gradle dependencies that cause the bugs (after):
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.android.support:support-v13:27.0.1'
compile 'com.android.support:cardview-v7:27.0.1'
compile 'com.android.support:recyclerview-v7:27.0.1'
compile 'com.android.support:design:27.0.1'
compile 'com.android.support:percent:27.0.1'
compile 'com.android.support:customtabs:27.0.1'
compile 'com.github.medyo:fancybuttons:1.5#aar'
compile 'com.sothree.slidinguppanel:library:3.2.1'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.balysv.materialmenu:material-menu:2.0.0'
compile 'com.github.d-max:spots-dialog:0.7#aar'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.0.4'
compile 'com.github.kenglxn.QRGen:android:2.2.0'
compile 'com.github.kenglxn.QRGen:core:2.2.0'
compile 'com.makeramen:roundedimageview:2.3.0'
compile 'org.bitbucket.b_c:jose4j:0.5.2'
compile 'com.wang.avi:library:2.1.0'
compile(name: 'tealium-5.0.4', ext: 'aar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
compile 'org.parceler:parceler-api:1.1.9'
annotationProcessor 'org.parceler:parceler:1.1.9'
compile 'com.facebook.android:facebook-android-sdk:4.15.0'
// Required -- JUnit 4 framework
testCompile 'junit:junit:4.12'
// Optional -- Mockito framework
testCompile 'org.mockito:mockito-core:1.10.19'
}
Production (before) gradle dependencies, that works:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:percent:23.1.0'
compile 'com.github.medyo:fancybuttons:1.5#aar'
compile 'com.sothree.slidinguppanel:library:3.2.1'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.google.android.gms:play-services-appindexing:9.0.1'
compile 'com.balysv.materialmenu:material-menu:2.0.0'
compile 'com.github.d-max:spots-dialog:0.7#aar'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.0.4'
compile 'com.github.kenglxn.QRGen:android:2.2.0'
compile 'com.github.kenglxn.QRGen:core:2.2.0'
compile 'com.makeramen:roundedimageview:2.3.0'
compile 'org.bitbucket.b_c:jose4j:0.5.2'
compile 'com.wang.avi:library:2.1.0'
compile(name: 'tealium-5.0.4', ext: 'aar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
compile 'org.parceler:parceler-api:1.1.9'
annotationProcessor 'org.parceler:parceler:1.1.9'
compile 'com.facebook.android:facebook-android-sdk:4.15.0'
// Required -- JUnit 4 framework
testCompile 'junit:junit:4.12'
// Optional -- Mockito framework
testCompile 'org.mockito:mockito-core:1.10.19'
}

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.

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'
}

Jar merging for debug throwing duplicate entry with android?

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
}

Cannot resolve Gradle Android dependency

I am trying to include the HoloColorPicker library (or for that matter any other library in my project), however, I cannot seem to get it to download.
The dependency section in my build.gradle file looks like:
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.+'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.android.support:support-v13:21.0.+'
compile 'com.larswerkman:HoloColorPicker:1.5+'
wearApp project(':Wearable')
The error message I get is as follows:
What went wrong: A problem occurred configuring project
':Application'. Could not resolve all dependencies for configuration
':Application:_debugCompile'.
Could not find any version that matches com.larswerkman:HoloColorPicker:1.5+.
Searched in the following locations:
file:/Users/Tom/Library/Android/sdk/extras/android/m2repository/com/larswerkman/HoloColorPicker/maven-metadata.xml
file:/Users/Tom/Library/Android/sdk/extras/android/m2repository/com/larswerkman/HoloColorPicker/
file:/Users/Tom/Library/Android/sdk/extras/google/m2repository/com/larswerkman/HoloColorPicker/maven-metadata.xml
file:/Users/Tom/Library/Android/sdk/extras/google/m2repository/com/larswerkman/HoloColorPicker/
Required by:
watchfaces2.0:Application:unspecified
I cannot seem to figure out why Android Studio is looking for the library under my local path as opposed to pulling the library down from the internet. How can I get past this issue?
Have you included Maven in your gradle file?
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.+'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.android.support:support-v13:21.0.+'
compile 'com.larswerkman:HoloColorPicker:1.5+'
wearApp project(':Wearable')
}
Just for complete the picture:
dependencies {
repositories {
mavenCentral()
}
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.1.+'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.android.support:support-v13:21.0.+'
compile 'com.larswerkman:HoloColorPicker:1.5+'
wearApp project(':Wearable')
}

Categories