Duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class - android

I am using LeanCloud as my push notification service provider but somehow when I run my app it gives me this error. Below is my dependencies:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile project(':react-native-push-notification')
compile project(':react-native-svg')
compile project(':react-native-fbsdk')
compile project(':react-native-picker')
compile project(':react-native-maps')
compile project(':react-native-wechat')
compile project(':react-native-code-push')
compile fileTree(dir: "libs", include: ["*.jar"])
compile ("com.android.support:appcompat-v7:23.0.1")
compile ("com.facebook.react:react-native:+") // From node_modules
compile ('com.facebook.android:facebook-android-sdk:[4.22.1)')
compile ('cn.leancloud.android:avoscloud-sdk:v4.4.4')
compile ('cn.leancloud.android:avoscloud-push:v4.4.4#aar'){
transitive = true
}
}
The exact error message:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class
I have tried to add "exclude group: 'com.squareup.okhttp3', module: 'okhttp'". It allows me to run the app but somehow I can't register my device on LeanCloud server.
I am stuck in this problem for so long. Thanks for any help or suggestions.

you can add this in your app.gradle
configurations.all {
// OkHttp 3.5.0+ includes the websockets API, so we need this to prevent a conflict
exclude module: 'okhttp-ws'
}
it may help you!
https://github.com/facebook/react-native/issues/12646

Add the below lines it may help you, working for me.
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }

Related

what the solution of Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'

I have tried to compile and I have no errors, but when I want to run the app I get this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/gson/annotations/Expose.class
my dependencies is :
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 files('src/include/gson-2.8.2-SNAPSHOT.jar')
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:23.2.0'
compile 'io.searchbox:jest-droid:2.0.1'
testCompile 'junit:junit:4.12'
I've noticed your question is a duplicate of this
As the accepted answer in that question states, you must multi-compiling GSON here
compile files('src/include/gson-2.8.2-SNAPSHOT.jar')
and in another library... I'm going to assume it's this one:
compile 'io.searchbox:jest-droid:2.0.1'
So I'd advise replicating the accepted answer for your project, like so:
compile('io.searchbox:jest-droid:2.0.1') {
exclude module: 'gson'
}

Java.util.zip.ZipException: duplicate entry: com/google/common/base/FinalizableReference.class

Why am getting this error it will not occurred when I sync the Gradle but when I'm running the project I am getting this error .
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/base/FinalizableReference.class
I don't know which dependency cause this error, My dependencies are .
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.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:percent:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.19.0'
compile 'com.google.android.gms:play-services-auth:11.0.0'
compile 'com.google.android.gms:play-services-location:11.0.0'
compile 'com.google.android.gms:play-services-maps:11.0.0'
compile 'com.google.android.gms:play-services-places:11.0.0'
compile 'com.google.maps.android:android-maps-utils:0.3.4'
compile 'io.nlopez.smartlocation:library:3.3.1'
compile 'com.appeaser.sublimenavigationviewlibrary:sublimenavigationviewlibrary:0.0.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.afollestad:sectioned-recyclerview:0.4.1'
compile 'com.github.medyo:fancybuttons:1.8.3'
compile 'com.basgeekball:awesome-validation:2.0'
compile 'com.github.michaelye.easydialog:easydialog:1.4'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Edit
I figured it out play service dependencies causing this problem. when I'm using 10.2.6 instead of 11.0.0 app is working perfectly, I just change dependecies to
compile 'com.google.android.gms:play-services-auth:10.2.6'
compile 'com.google.android.gms:play-services-location:10.2.6'
compile 'com.google.android.gms:play-services-maps:10.2.6'
compile 'com.google.android.gms:play-services-places:10.2.6'
but I want to use latest version of play-services 11.0.0 but it gives me the above problem. How to resolve this problem? Any help would be appriciated Thanks.
Finally problem is solved. Seems like its a bug google resolved this issue in updated version.
Use play Service Version 11.0.1
In project level gradle use
classpath 'com.google.gms:google-services:3.1.0'
Sometimes, this issue happens because of including different version of play-services (or some other libraries). Have a look at app dependencies using below:
gradle app:dependencies
or if you are using Gradle wrapper
./gradlew app:dependencies
There might be some other third party library that is using an older version of library. If that is the case, exclude the older library from the third party library and include the latest one.
You can do something like this:
compile ('com.thirdpartylib.android:library-sdk:8.3.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.android.gms', module: 'play-services-gcm'
compile 'com.android.support:support-v4:26.0.0'
compile 'com.android.support:support-annotations:26.0.0'
compile 'com.google.android.gms:play-services-gcm:11.2.0'
}
This should resolve any duplicate entry, the main reason for the issue

TransformException: java.util.zip.ZipException: duplicate entry: com/activeandroid/ActiveAndroid.class

Please let me know what exactly require here, I can see same source is running fine in Android Studio Emulators but in third party emulators like bluestacks I can see following errors.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/activeandroid/ActiveAndroid.class
Please check my gradle dependencies here.
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile files('library/android-viewbadger.jar')
compile files('library/robobinding-0.8.1.jar')
compile files('library/activeandroid-3.1-SNAPSHOT.jar')
compile project(':Android-Validator')
// compile files('library/java-rt-jar-stubs-1.5.0.jar')
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.0.1'
compile ('com.android.support:appcompat-v7:25.0.1'){
exclude module: 'support-v4'
}
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.f2prateek.progressbutton:progressbutton:2.1.0#aar'
compile files('library/afreechart-0.0.4.jar')
compile 'commons-io:commons-io:+'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.google.guava:guava:16+'
compile 'joda-time:joda-time:2.9.4'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.sun.codemodel:codemodel:2.4.1'
compile 'org.apache.httpcomponents:httpmime:4.5.1'
compile 'ch.acra:acra:4.9.0'
compile 'org.jsoup:jsoup:1.10.2'
compile 'org.apache.commons:commons-lang3:3.4'
compile ('org.simpleframework:simple-xml:2.7.1'){
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile files('library/pdfjet-5.75.jar')
compile 'log4j:log4j:1.2.17'
compile 'com.splunk:mint-android-sdk:5.2.1'
compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
compile files('library/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}
This issue usually came when the same class is added in gradle twice.
Why you are using
compile files('library/activeandroid-3.1-SNAPSHOT.jar')
and
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
This is the reason for this.Try adding it once only and then build the gradle and run

Authorizing google API error

I'm trying to Authorizing and using googel API for android but when I try to configure build dependencies and sync the project it give me an error like
Error:Execution failed for task ':app:prepareDebugAndroidTestDependencies'.> Dependency Error.
See console for details.
build gradle (app):
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:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.api-client:google-api-client:1.22.0'
compile 'com.google.api-client:google-api-client-android:1.22.0'
compile 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'
how can I solve this?
Not sure, but I think your google apis are conflicting
compile 'com.google.android.gms:play-services-auth:10.2.0'
and
compile 'com.google.api-client:google-api-client:1.22.0'
Might internally be using other dependencies, with different versions.
Try running: /gradlew app:dependencies to see all your dependencies

Gradle build fails with duplicates when adding google-api-client

I am adding code to my project which requires google-api-client, when I add it via the gradle dependency, I get a duplicate error.
Here is the gradle dependency list
dependencies {
compile 'com.adobe.creativesdk:image:4.0.0'
// compile project(':showcaseView')
compile project(':facebook')
compile project(':SwipeMenuListView')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:22.2.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:7.5.+'
compile 'com.google.android.gms:play-services-appinvite:7.5.0'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.apache.httpcomponents:httpcore:4.3.3'
compile 'commons-codec:commons-codec:1.9'
compile 'commons-io:commons-io:2.4'
compile 'com.google.gdata:core:1.47.1'
compile files('libs/tape-1.1.0.jar')
compile files('libs/gdata-photos-meta-2.0.jar')
compile 'com.google.api-client:google-api-client:1.20.0'
// compile 'com.google.http-client:google-http-client:1.20.0'
// compile files('libs/android-oauth-client-0.4.5.jar')
}
Here is the error that I receive
Execution failed for task ':FloomIt:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/common/collect/package-info.class
If I remove the google-api-client line from the dependency list, the error goes away.
Any suggestions on how to proceed?
That is because com.google.api-client:google-api-client depends on com.google.guava:guava-jdk5 but com.google.gdata:core depends on com.google.guava:guava. The JDK5 split is unfortunate.
Gradle allows you to override dependencies. Try replacing the gdata dependency with something like:
compile('com.google.gdata:core:1.47.1') {
exclude group: 'com.google.guava', module: 'guava'
}

Categories

Resources