Dependency resolved to an incompatible version - android

I need to use dialogFlow sdk along with firestore sdk. In separate projects I can use normally, but when I join them, a dependency failure occurs
I have tried to use several different versions of them but to no avail
android {
/* Code */
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-firestore:21.0.0'
//erro aqui
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
//implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'ai.api:sdk:2.0.5#aar'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'commons-io:commons-io:2.4'
implementation('ai.api:libai:1.4.8') {
exclude module: 'log4j-core'
}
implementation 'com.google.dagger:dagger:2.22'
kapt 'com.google.dagger:dagger-compiler:2.16'
implementation 'io.github.dreierf:material-intro-screen:0.0.6'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.android.billingclient:billing:2.0.3'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'//rede
implementation 'com.squareup.retrofit2:converter-jackson:2.4.0'
implementation 'com.github.pchmn:MaterialChipsInput:1.0.8'
implementation 'com.github.clans:fab:1.6.4'//floatingActionMenu
implementation 'com.github.ialokim:android-phone-field:0.2.3'
implementation 'com.google.cloud:google-cloud-dialogflow:0.108.0-alpha'
//erro aqui
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.stepstone.apprating:app-rating:2.3.1'
}
apply plugin: 'com.google.gms.google-services'
googleServices { disableVersionCheck = false }
The error that is displayed in the attempt to compile:
Dependency resolved to an incompatible version:
Dependency(fromArtifactVersion=ArtifactVersion(groupId=io.grpc, artifactId=grpc-okhttp, version=1.21.0), toArtifact=Artifact(groupId=io.grpc, artifactId=grpc-core), toArtifactVersionString=[1.21.0])
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[1.21.0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: io.grpc:grpc-okhttp:1.21.0 -> io.grpc:grpc-core#[1.21.0], but grpc-core version was 1.23.0.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the artifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-firestore#21.0.0
-- Project 'app' depends onto com.google.cloud:google-cloud-dialogflow#0.108.0-alpha
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dependency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your build.gradle file.

I was able to solve by adding this to build.gradle
android {
//
configurations.all {
exclude group:'com.google.api.grpc',module:'proto-google-common-protos'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.guava',module: 'guava-jdk5'
}
}
The solution and explanation of the problem comes from here

Related

How to install "Cloud Text-To-Speech" with Gradle?

I would like to use Cloud Text-To-Speech.
On the documentation page I see that I have to install the client library. On that page you see the code for Maven but in my Android Studio, I am using Gradle and I have no idea how to install it with Gradle.
On MVNRepository I have noticed that I have to use compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1'. So on on my application (app -> build.gradle), I have inserted that line to the dependencies. So it looks like this:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
But that gives me the error: More than one file was found with OS independent path 'META-INF/INDEX.LIST'.
Also, Android Studio tells me "compile is deprecated; replace with implementation". If I replace it, I'll get the error: Cannot fit requested classes in a single dex file (# methods: 151443 > 65536)
I also tried to use:
packagingOptions {
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
}
I cleaned my project and restarted the app but then I get the error: Cannot fit requested classes in a single dex file (# methods: 147675 > 65536)
This is too annoying! How can I simply install that library??
Instead of compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1', I needed to use implementation 'com.google.cloud:libraries-bom:4.3.0'.

Gradle Libraries Conflict

I'm having a conflict in libraries and failing to resolve it and the error is always
Multiple dex files define Lorg/apache/http/impl/client/DefaultRequestDirector;
The project compiles and runs if I don't implement the jackson2 and Robospice libraries, however, I need so what to do.
here's my gradle
dependencies {
implementation files('libs/speedchecker-android-sdk-1.3.jar')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.code.gson:gson:2.8.4'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1#aar'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'info.hoang8f:android-segmented:1.0.6'
implementation 'com.google.code.ksoap2-android:ksoap2-android:2.6.0'
testImplementation 'junit:junit:4.12'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
implementation('com.google.http-client:google-http-client-jackson2:1.19.0') {
exclude module: 'commons-io'
exclude module: 'xpp3'
exclude group: 'stax'
}
implementation('com.octo.android.robospice:robospice-google-http-client:1.4.14') {
exclude module: 'commons-io'
exclude group: 'org.apache.commons'
}
}
After trying for several hours, I noticed that the conflict is resulting from the following 3 (the two libraries came with the speed test jar file library when i bought it, so after upgrading the build tools the conflict occurred)
implementation files('libs/speedchecker-android-sdk-1.3.jar')
implementation('com.google.http-client:google-http-client-jackson2:1.19.0') {
exclude module: 'commons-io'
exclude module: 'xpp3'
exclude group: 'stax'
}
implementation('com.octo.android.robospice:robospice-google-http-client:1.4.14') {
exclude module: 'commons-io'
exclude group: 'org.apache.commons'
}
change gradle.property and multidexenable= true;
org.gradle.jvmargs=-Xmx1024m
compile 'com.android.support:multidex:1.0.1'
and also include
multiDexEnabled true
it seems like you're mixing libraries that shouldn't be mixed
looking at your build file these libraries are conflicting:
firebase contains both versions 16.0.1 and 17.1.0 which are conflicting and;
there are dependencies to both firebase and gcm (version 15.0.1 ) which are also conflicting
get rid of those and it should build without issues

Google Play Services Base Being Resolved to Version not in Dependencies

While updating the google-play-services libraries used in my React Native Android project, upon building I'm getting this error:
The library com.google.android.gms:play-services-base is being
requested by various other libraries at [[15.0.1,15.0.1]], but
resolves to 10.2.4. Disable the plugin and check your dependencies
tree using ./gradlew :app:dependencies.
But when I run ./gradlew :app:dependencies there is no mention of version 10.2.4 of any library.
Here is the dependencies section of my build.grade:
implementation project(':react-native-cookies')
implementation(project(':react-native-google-places')) {
exclude group: 'com.google.android.gms';
}
implementation(project(':react-native-maps')) {
exclude group: 'com.google.android.gms';
}
implementation(project(':react-native-fbsdk')) {
exclude(group: 'com.facebook.android', module: 'facebook-android-sdk');
exclude group: 'com.android.support';
}
implementation 'com.facebook.android:facebook-android-sdk:4.22.1'
implementation(project(':tipsi-stripe')) {
exclude group: 'com.android.support';
exclude group: 'com.google.android.gms';
exclude group: 'com.google.firebase';
}
implementation(project(':react-native-camera')) {
exclude group: 'com.android.support';
exclude group: 'com.google.android.gms';
}
implementation(project(":react-native-google-signin")){
exclude group: "com.google.android.gms";
}
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.android.support:support-core-utils:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.gms:play-services-wallet:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
How can I resolve this issue? Thank you
EDIT: I noticed that my react-native-google-places dependency was behind a version, and after updating it the error message has changed to:
The library com.google.android.gms:play-services-base is being requested
by various other libraries at [[15.0.1,15.0.1]], but resolves to
11.6.2.
Looking at the build.gradle for react-native-google-places reveals that it is indeed including com.google.android.gms:play-services-base:11.6.2, but I would have expected the dependency to be excluded due to the exclude group: in my app's build.gradle (see above).

Android Error while merging dex archives

After updating my android studio and build tool version get this error.I have tried all the solution available for this problem over internet , but not successful
don't know why this is happening ??
Android studio version: 3.1
Gradle version": 4.4
Gradle plugin : 3.1
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
My build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.abc.abc"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true //Tryed this but not worked
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url 'https://github.com/jitsi/jitsi-maven-repository/raw/master/releases'
}
// maven { url "https://dl.bintray.com/michelelacorte/maven/" }
mavenCentral()
}
configurations {
all*.exclude module: 'support-v4'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:support-fragment:27.1.0'
// multipart entity
implementation('org.apache.httpcomponents:httpmime:4.+') {
exclude module: "httpclient"
}
implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
// implementation 'com.wonderkiln:camerakit:0.13.0'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'org.jitsi.react:jitsi-meet-sdk:1.9.0'
// compile 'com.google.code.gson:gson:2.2.4'
// compile 'com.android.support:support-emoji:26.0.1'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'com.yalantis:ucrop:2.2.0-native'
implementation 'com.pnikosis:materialish-progress:1.7'
implementation 'org.igniterealtime.smack:smack-android-extensions:4.2.0'
implementation 'org.igniterealtime.smack:smack-experimental:4.2.0'
implementation 'org.igniterealtime.smack:smack-tcp:4.2.0'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation 'com.googlecode.libphonenumber:libphonenumber:7.0.4'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.google.android.gms:play-services-places:11.8.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.eyalbira.loadingdots:loading-dots:1.0.2'
implementation 'de.hdodenhof:circleimageview:2.1.0'
// implementation 'com.google.android.exoplayer:exoplayer:2.7.1'
// compile 'it.michelelacorte.swipeablecard:library:2.3.0#aar'{
// exclude module: 'appcompat-v7'
// exclude group: 'com.android.support'
// }
// BUTTER KNIFE
implementation('com.jakewharton:butterknife:8.5.1') {
exclude module: 'appcompat-v7'
exclude group: 'com.android.support'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
// implementation project(':libemoji')
implementation 'com.android.support:support-v13:27.1.0'
}
It's waste almost my 10 days...
most confusing error ever encounter..
This error happens if your code has two different modules of google-play-services or support-v4 which are using different versions of these libraries.
Check the dependencies of the libraries you are using in your project or use
gradle app:dependencies
to see dependency tree of your project and then when you find out which libraries is used with different version, add it to your dependencies with correct version. For example if google-play-services:location:11.2.0 appeared in your dependencies, replace it with google-play-services:location:11.8.0
Usually you will see a warning or error message in your build.gradle file (i.e. one dependency will be marked with red underline showing it cause version mismatch) in such cases.
In my case, project and module's package name is same. When running in debug mode, everything is okey. But when i want to build release mode. I got this error. Renaming package name is the solution for me.

Dagger Annotation Processor fails to find com/google/common/collect/SetMultimap

I have been charged with integrating Dagger in our existing project and I am having a bit of a problem with the dagger annotation processor.
My environment is pretty restricted so I cannot just use jcenter() or even Google Maven to get dependencies. We have an internal Ivy repo that stores and manages all of our Dependencies.
That said, I have pulled down all the dependencies that Dagger requires but I still have an issue. Gradle sync finishes successfully and resolves the dependencies, however when I go to build I get the following error.
error: Bad service configuration file, or exception thrown while
constructing Processor object: javax.annotation.processing.Processor:
Provider dagger.internal.codegen.ComponentProcessor could not be
instantiated: java.lang.NoClassDefFoundError:
com/google/common/collect/SetMultimap
Clearly I am missing a dependency as when I specifically specify and allow jcenter() and Google Maven as repositories, which I can do for testing purposes, but for prod building this cannot be allowed, I am able to build with no exceptions.
Now a strict reading of the error tells me that Dagger cannot find com.google.comm.collect.SetMutliMap.
I have searched quite a bit trying to find this dependency and about all I can find is that this file is a part of Guava or at least some of its functions are.
One thing to note is I am using the following version of gradle:
classpath 'com.android.tools.build:gradle:3.0.0'
Here is my dagger dependency in build.gradle which is an older version:
//Dagger
compile 'com.google.dagger:dagger:2.10'
annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
Other dependencies:
//lifecycle libs
compile "android.arch.lifecycle:runtime:1.0.3"
compile "android.arch.lifecycle:extensions:1.0.0"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
compile 'de.greenrobot:eventbus:2.4.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'commons-io:commons-io:2.4'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.github.ganfra:material-spinner:2.0.0'
compile 'com.nulab-inc:zxcvbn:1.1.3'
compile('com.google.android.gms:play-services-vision:10.2.1') {
exclude group: 'com.android.support'
}
compile 'org.zakariya.stickyheaders:stickyheaders:0.7.6'
compile 'com.google.code.gson:gson:2.8.0'
compile('com.google.android.gms:play-services-gcm:10.2.1') {
exclude group: 'com.android.support'
}
compile('com.google.android.gms:play-services-maps:10.2.1') {
exclude group: 'com.android.support'
}
compile('com.google.android.gms:play-services-location:10.2.1') {
exclude group: 'com.android.support'
}
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:support-annotations:26.1.0'
//retrofit dependencies
compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
Due to my restricted environment, I cannot update dependencies as I would like to do, so working within what I have, does anyone have any ideas on how to resolve this?
Thanks
As it turns out com.google.common.collect is part of com.google.guava
With that find in hand I found a solution that works. For whatever reason dagger-compiler was not resolving its own dependency, which is com.google.guava.
My solution consists of excluding the guava dependency from the compiler and adding it to the annotationProcessor path. I also exclude find bugs for my case as an older version is a dependency in our test project.
annotationProcessor ('com.google.guava:guava:22.0'){
exclude group: 'com.google.code.findbugs'
}
annotationProcessor('com.google.dagger:dagger-compiler:2.13') {
exclude group: 'com.google.guava'
}

Categories

Resources