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

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

Related

Error while compiling signed apk (release build) in Android Studio 3.0

How to fix this issue while compiling release build in Android Studio 3.0
Error:Error: json defines classes that conflict with classes now
provided by Android. Solutions include finding newer versions or
alternative libraries that don't have the same problem (for example,
for httpclient use HttpUrlConnection or okhttp instead), or
repackaging the library using something like jarjar.
[DuplicatePlatformClasses]
Here's the build.gradle
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.google.android.gms:play-services-base:11.4.2'
compile 'com.google.android.gms:play-services-gcm:11.4.2'
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.google.android.gms:play-services-maps:11.4.2'
compile 'com.google.android.gms:play-services-analytics:11.4.2'
compile 'com.facebook.android:facebook-android-sdk:4.27.0'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.firdausmaulan:GlideSlider:1.0.0'
compile 'com.arifian.networkstatelistener:lib:1.0.0'
compile 'com.arifian.view:centeredtoolbar:1.0.5'
compile 'com.sherlockshi.widget:aspectratioimageview:1.0.1'
compile 'com.wdullaer:materialdatetimepicker:3.2.2'
compile 'com.github.rey5137:material:1.2.4'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.wefika:horizontal-picker:1.1.1'
compile 'com.mixpanel.android:mixpanel-android:5.1.4'
compile 'com.github.nkzawa:socket.io-client:0.5.2'
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-messaging:11.4.2'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
}

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.

twilio Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug

I've seen many questions about this, but none of them are working.
compile 'com.twilio.sdk:twilio-java-sdk:5.10.0'
This is the Twilio dependency I'm using. Using that, I get this warning:
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6
is ignored for debug as it may be conflicting with the internal
version provided by Android.
My gradle dependencies:
compile('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.9.3#aar') {
transitive = true
}
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 'cn.pedant.sweetalert:library:1.2'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile "com.google.android.gms:play-services-auth:${firebaseVersion}"
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile "com.android.support:design:${supportLibVersion}"
compile "com.google.firebase:firebase-database:${firebaseVersion}"
compile "com.google.firebase:firebase-storage:${firebaseVersion}"
compile 'com.afollestad.material-dialogs:core:0.8.6.1'
compile 'com.novoda:merlin:0.8.0'
compile 'biz.kasual:materialnumberpicker:1.2.1'
compile 'com.firebaseui:firebase-ui-database:0.4.3'
compile 'com.github.rey5137:material:1.2.2'
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile 'com.github.bumptech.glide:glide:3.7.0'
compile "com.android.support:support-v4:${supportLibVersion}"
compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile "com.google.firebase:firebase-crash:${firebaseVersion}"
compile 'org.jetbrains:annotations-java5:15.0'
compile "com.google.firebase:firebase-auth:${firebaseVersion}"
compile "com.google.firebase:firebase-messaging:${firebaseVersion}"
compile "com.android.support:support-vector-drawable:${supportLibVersion}"
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4'
"compile 'com.android.support:palette-v7:${supportLibVersion}"
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
compile 'com.github.Commit451:NativeStackBlur:1.0.5'
compile 'com.googlecode.libphonenumber:libphonenumber:7.2.2'
compile project(':MaterialSearchView')
compile 'com.sparkjava:spark-core:2.5'
compile group: 'com.twilio.sdk', name: 'twilio-java-sdk', version: '7.0.0-rc-10'
compile 'org.slf4j:slf4j-simple:1.6.1'
What can I do to fix this error?

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

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
}

Categories