Recently I started to develop and Android Kotlin project and I need to use the BigQuery library (from Google). According to the documentation, it not exists any client library developed in Kotlin but I reviewed the Java library so I decided to impor it...
When I put the gradle statement in app-module of my project:
implementation platform('com.google.cloud:libraries-bom:26.1.5')
implementation 'com.google.cloud:google-cloud-bigquery'
I got this ouput error:
Duplicate class org.jetbrains.annotations.NotNull found in modules annotations-13.0 (org.jetbrains:annotations:13.0) and auto-value-1.10 (com.google.auto.value:auto-value:1.10)
Duplicate class org.jetbrains.annotations.Nullable found in modules annotations-13.0 (org.jetbrains:annotations:13.0) and auto-value-1.10 (com.google.auto.value:auto-value:1.10)
Go to the documentation to learn how to Fix dependency resolution errors.
Could you help someone, please?
In order to solve it, I tried the following:
In build.gradle [app-module]:
configurations {
cleanedAnnotations
implementation.exclude group: 'org.jetbrains' , module:'annotations'
}
and
configurations {
cleanedAnnotations
implementation.exclude group:'com.google.auto.value' , module:'auto-value:1.10'
}
but still not working.
In build.gradle [app-module] in "android{}" section:
configurations.all {
resolutionStrategy {
exclude group: "org.jetbrains", module: "annotations-13.0"
}
}
but I didn't get any success....
Related
I have a native android project with a lot of submodules and custom flutter library that added as a submodule as well and dependency set up as described here: option B with settings.gradle
the issue is that some submodules are uses exoplayer, and flutter library uses it as well. so, while building I got a lot of dependency issue:
Duplicate class com.google.android.exoplayer2.video.spherical.Projection$SubMesh found in modules jetified-exoplayer-core-2.10.1-runtime (com.amazon.android:exoplayer-core:2.10.1) and jetified-exoplayer-core-2.10.1-runtime (com.google.android.exoplayer:exoplayer-core:2.10.1)
it seems force does not working in this case:
configurations.all {
resolutionStrategy.force 'com.google.android.exoplayer:exoplayer-core:2.10.1'
}
how can I exclude exoplayer from flutter lib?
Only option I found for now is to build .arr and exclude from here, but it not working for me as flutter library also is in development.
replace
implementation project(':flutter')
with
implementation(project(":flutter")) {
exclude module: 'exoplayer-core'
exclude module: 'exoplayer-hls'
exclude module: 'exoplayer-dash'
exclude module: 'exoplayer-smoothstreaming'
}
"(" and ")" around "project" is required
When I add the UCrop library version 2.2.3 and Cometchat SDK version 1.6.+ I get the following error :
Duplicate class okhttp3.Address found in modules okhttp-3.11.0.jar (com.squareup.okhttp3:okhttp:3.11.0) and okhttp-3.12.0.jar (com.cometchat:pro-android-chat-sdk:1.6.0)
The problem is that none of the previously asked questions have answers that solved my problem because most of them use the 'compile' method which is now deprecated.
I read many questions here on stackoverflow about the same topic, including
this , this.
I've also tried excluding okhttp3 library from one of the packages so that only one is used , using
implementation('com.github.yalantis:ucrop:2.2.3' )
{
exclude group: 'com.cometchat', module: 'okhttp3'
}
I would appreciate it if someone could explain to me how excludes work in gradle and what's wrong with the code that I wrote.
Instead of excluding okhttp3 from com.cometchat group try doing this
implementation('com.cometchat:pro-android-chat-sdk:1.6.0') {
configurations {
compile.exclude module: 'okhttp'
}
}
The conflict is due to your both UCrop and CometChat dependencies internally uses okhttp library.To resolve this problem you have to exclude conflicting library.
Excluding transitive dependency can be done two different ways.
Exclude transitive dependency by configuration
Exclude transitive dependency by dependency
To read more about gradle dependency conflict cause and solution you can check out this link
https://www.concretepage.com/build-tools/gradle/gradle-exclude-transitive-dependency-example
I started migration from build.gradle (Groovy) to build.gradle.kts (Kotlin DSL). The thing is that com.google.common.util.concurrent.ListenableFuture (from com.google.guava) exists in several dependecies. Because of that build fails with java.lang.RuntimeException: Duplicate class ... error.
Previously (when I had build.gradle in Groovy) this problem was solved with this snippet:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
But I can't find anything similar using Kotlin DSL.
Could you please provide Kotlin alternative for the snippet above or suggest any other solution on how to deal with this?
This works with the Gradle Kotlin DSL:
configurations {
all {
exclude(group = "com.google.guava", module = "listenablefuture")
}
}
This might work (though I haven't tried it):
configurations.forEach { it.exclude("com.google.guava", "listenablefuture") }
For two group you can use like this:
configurations.forEach {
it.exclude("com.google.guava", "listenablefuture")
it.exclude(group = "org.jetbrains", module = "annotations")
}
While I was trying to use stetho-timber Library in my Android application I faced this problem:
Error:Module 'com.facebook.stetho:stetho-timber:1.3.1' depends on one
or more Android Libraries but is a jar
After inspecting in its codes I found that it uses timber v3.0.1!
Just add this to your build.gradle dependencies tag to exclude timber within the stetho library,
cause it is an old version and conflicts with new one:
dependencies {
compile ("com.facebook.stetho:stetho-timber:1.3.1") {
exclude group: "com.jakewharton.timber", module: "timber"
}
.
.
.
I got this error message when trying to add RxPresso(https://github.com/novoda/rxpresso/) to my project:
Warning:Conflict with dependency 'io.reactivex:rxjava'. Resolved versions for app (1.1.9) and test app (1.0.14) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
I'm currently using rxjava 1.1.9. How can I add RxPresso in my project?
Thx a lot
To avoid any problems with RxJava and Android Support Libraries version, go to your app/build.gradle file and in dependencies section paste:
androidTestCompile ('com.novoda:rxpresso:0.2.0') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'io.reactivex'
}
You can explicitly tell Gradle which version to use, by adding into your build.gradle next snippet
configurations.all {
// check dependency tree with gradlew :app:dependencies
// avoid wildcard '+' dependencies used at 3rd libraries forcing them to exact version
resolutionStrategy.force "io.reactivex:rxjava:1.1.9"
}