Trying to run my app, this is an error I'm getting from the Gradle Build:
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find any version that matches com.google.android.gms:play-services-vision:9.4.0.+.
Versions that do not match:
11.0.2
11.0.1
11.0.0
10.2.6
10.2.4
+ 17 more
Required by:
project :app
Here's what my dependencies look like:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// Important - the CameraSource implementation in this project requires version 8.1 or higher.
compile 'com.android.support:support-v4:24.2.0'
compile 'com.google.android.gms:play-services-vision:9.4.0.+'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
I've tried to update the play services through Tools>Android SDK>..
I've read some other posts and people have similar problems, but the fixes don't work. I was also hoping to understand the issue a bit more.
Thanks
Try :
A full clean and rebuild
Uninstalling/installing android support repository
Your specification of "9.4.0.+" is not correct. Maybe you meant something like "9.4.+", but at any rate dynamic dependencies aren't a great idea IMHO. The error message lists the most recent version available on your machine as "11.0.2" (which is the most recent version at the time of writing). Use that instead. According to your comment above, this part of your problem is clearly resolved.
As to your other problem ("support libraries must use the same version"), something (play-services-vision or constraint-layout) most likely pulls in a different version of some part of the support libraries. You should look at this SO question to track down where your dependencies are coming from. You will need to make sure and use compatible versions of everything. In the end, it may suffice to just make sure you have the latest version of each.
Related
I got errors
Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-26.0-android.jar (com.google.guava:guava:26.0-android) and jetified-listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)
Go to the documentation to learn how to Fix dependency resolution errors.
After update
classpath 'com.android.tools.build:gradle:3.5.3'
to
classpath 'com.android.tools.build:gradle:3.6.1'
and gradle 5.4.1 to 5.6.4
Problem solved when downgrade
implementation 'com.google.firebase:firebase-firestore:21.4.1'
to
implementation 'com.google.firebase:firebase-firestore:21.4.0'
Is this a bug of firebase/firestore?
After updating Firebase, I encountered this issue as well.
Fix the conflict by adding the following package to your build.gradle
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
I am using latest version of firebase firestore i.e.
implementation 'com.google.firebase:firebase-firestore:21.4.3'
and adding this line worked for me:
implementation 'com.google.guava:guava:27.0.1-android'
I think part of the issue is that Android Studio (or maybe the Gradle Plugin, however that is handled) is recommending to update the version of the Firestore dependency to 21.4.1 (likely depends on the order of repositories in your build.gradle - not sure on that). And yes, it seems that 21.4.1 causes the issue.
So yeah, just ignore that recommendation and leave it at 21.4.0. Also...
Firebase Docs show 21.4.0 as the correct version.
MVN Repository shows 21.4.1 as the latest release.
Google Maven Repo also lists 21.4.1 as the latest release.
For the one who does not find a solution, this helped me.
Add this dependency in your app/build.gradle file.
implementation "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava"
Source:
https://github.com/firebase/firebase-android-sdk/issues/1320#issuecomment-601159166
The latest version of firestore is:
implementation 'com.google.firebase:firebase-firestore:21.4.0'
If you have not added firestore as a dependency and still getting this error add below dependency to gradle
implementation group: 'com.google.guava', name: 'guava', version: '27.0.1-android'
implementation 'com.google.guava:guava:28.2-android'
add this to your gradle and you're good to go
I just added
implementation group: 'com.google.guava', name: 'guava', version: '27.0.1-android'
into my dependencies.
I'm writing Minecraft Plugin using IntelliJ IDEA Ultimate with gradle. I have added dependency org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT as compileOnly. During development, I noticed that gradle compiles my code in different way than IntelliJ does. For example, IntelliJ was unable to accept addPassenger on Boat, but gradle compiled it. In the opposite way, if I changed it into setPassenger, IntelliJ didn't mark it as error, but gradle failed to compile. I tried to invalidate caches, reimport, clean, even remove %userprofile%\.gradle directory, nothing helped. As a POC I changed compileOnly to compile and it worked well, IntelliJ and gradle compilation results were consistent. What's the reason?
Ok, I found the solution (and forgot about this question).
I had been using multiple dependencies, and one load another with older version that I loaded implicitly in my build.gradle. However, they weren't exactly the same dependencies, but parallel ones. So gradle could not choose higher version of one dependency. Solution was to exclude this one explicitly loaded dependency and everything worked well.
Before:
dependencies {
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.0.1'
compileOnly group: 'org.spigotmc', name:'spigot-api', version: '1.15.1-R0.1-SNAPSHOT'
}
After:
dependencies {
compileOnly('com.sk89q.worldedit:worldedit-bukkit:7.0.1') {
exclude `org.bukkit:bukkit:1.15.1-R0.1-SNAPSHOT`
}
compileOnly group: 'org.spigotmc', name:'spigot-api', version: '1.15.1-R0.1-SNAPSHOT'
}
I'm using Dagger 2 (first time user of the DI library) with Android Studio (AS 2.1.2 - SDK 24), and obviously my first thought is "What dependencies do I need in order to use it?"
Having looked at examples I can see that you need in the top level build.gradle file you need a annotation processor plugin:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Now the dependencies in the Module level build.gradle apply the apt plugin for the Module so I end up with something like:
apply plugin: 'com.neenbedankt.android-apt'
// other generic settings - android / buildTypes etc.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
.
.
compile 'com.google.dagger:dagger:2.6'
apt 'com.google.dagger:dagger-compiler:2.6'
provided 'javax.annotation:jsr250-api:1.0'
}
PROBLEM
I have been using, for sometime, the Jack Tool Chain and Java 8 in my projects and found out the above configuration is incompatible with Jack.
Having researched what I needed in order for Jack and Dagger 2 to cooperate I changed the following:
gradle-wrapper.properties :
Changed to :
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
build.gradle (Top Level)
Changed to:
classpath 'com.google.guava:guava:19.0' // added after getting NoSuchMethod Error - it solved the issue
classpath 'com.android.tools.build:gradle:2.2.0-alpha7'
build.gradle (Module Level)
Changed to:
compile 'com.google.dagger:dagger:2.6'
annotationProcessor 'com.google.dagger:dagger-compiler:2.6'
With these changes I was able to use the Jack Tool Chain, and build a small project. However without changing any code I started having trouble with my Component creation - in a simple line of code : testComponent = DaggerTestComponent.builder().build(); the word DaggerTestComponent became red (obviously the Dagger 2 library wasn't working as it should). I managed to resolve the error by a good old invalidate caches, clean and rebuild. However I have been plagued with random errors each time I try and build the small test project - I have managed a couple times to run the app (and it works as expected), but obviously it is quite temperamental.
QUESTION
So the question, and I apologise for it taking this long, but thought that all of the above was relevant,
Is there a more 'Stable' setup than what I'm using at the moment? Has anyone else encountered these problems?
Obviously I don't have to use the Jack tool chain and Java 8, but I'd rather not compromise if I don't have to!
The moment I added the android support annotations to my dependencies
compile 'com.android.support:support-annotations:20.0.0'
I got this error:
Error Code:
2 Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
build.gradle
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.android.support:support-annotations:20.0.0'
}
Anybody else experienced this issue? I have tried the solutions from here.
The problem is that android-support-annotations.jar used to be a separate library containing the android annotations, but for some reason these annotations are already included in recent versions of the android-support-v4.jar file.
Deleting the annotations jar solved the issue.
Build->clean Project ,and it worked
I deleted the android-support-v4.jar and it worked.
If this is cordova / ionic project this worked for me
add these line to build.gradle under platforms/android after line number 22 i.e after apply plugin: 'android'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
Solved this exact issue in a Cordova project that used the facebook plugin. I was able to successfully build by commenting out this line from platforms\android\project.properties, as shown:
# cordova.system.library.1=com.android.support:support-v4:+
And by commenting out this line from platforms\android\build.gradle, as shown:
// compile "com.android.support:support-v4:+"
Then doing the build. The problem started when I installed (katzer/cordova-plugin-local-notifications) which added these lines, but it created a conflict since the library it was adding to the build was already part of the facebook plugin build.
As other users said, the first elements to troubleshoot are dependencies. Although, sometimes you can struggle for hours and you don't find any problem so you can focus on the build process instead.
Changing the way in which the .dex files are produced sometimes solves the problem. You can go through these steps:
Open your Build.gradle (app) file
Search for the task dexOptions
Change it to:
dexOptions {
incremental false
}
If you don't find the task in your file then you can add it.
For me the reason was the new data-binding lib
com.android.databinding:dataBinder:1.0-rc2
it somehow used a conflicting version of the annotations lib, which I could not force with
configurations.all {
resolutionStrategy {
force group: 'com.android.support', name: 'support-v4', version: '23.1.0'
force group: 'com.android.support', name: 'appcompat-v7', version: '23.1.0'
force group: 'com.android.support', name: 'support-annotations', version: '23.1.0'
}
}
but the new rc3 and rc4 versions seem to have fixed it, so just use those versions
I had the same problem , but i deleted build files from the build folder
projectname/app/build
and it removed all the related error. "can't clean the project" and also "dex errow with $anim"
I managed to fix this issue. The reason was that I included the android support library 19.0.0 as a dependency, but 19.1.0 is required. See here for more information
So it has to be
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.android.support:support-annotations:20.0.0'
}
If you import AppCompat as a library project and you also have android-support-annotations.jar in libs elsewhere, make sure to import everywhere AppCompat library only (it already includes this annotations lib). Then delete all android-support-annotations.jar to avoid merging multiple versions of this library.
Updating Android SDK Tools fixed it for me, now it just sees the copy in android-support-v4.jar.
I had the same problem when using ant, and the annotations library was being included automatically by an outdated sdk.dir/tools/ant/build.xml.
Clean project works as a temporary fix, but the issue will reappear on next compilation error.
To fix more reliably, I had to update the dependency to android support-v4 to com.android.support:support-v4:22.2.0.
Put in your build.gradle the dependency of support-annotations according with your compileSdkVersion. For instance: A project with the compileSdkVersion 25 you can put the following dependence:
compile 'com.android.support:support-annotations:25.0.1'
This will solve your problem.
In my case I had a file called cache.xml under /build/intermediates/dex-cache/cache.xml in the root project folder. I deleted this file, rebuild the project and it worked for me.
I deleted the android-support-v4.jar and it worked.
Explain - android-support-v4.jar is conflicting with my other .jar files of project\libs files ** specially when you are running with java 8 on AS.
Put android-support-v4.jar in your libs folder in eclipse. Clean and build the project. It will resolve the issue.
Another reason that messages such as these can come up in Android Studio when building and launching can be the cause of application tags in your libraries.
If you have several Android Library projects that you imported as modules. Go into those projects and remove the <application> ... </application> tags and everything between them. These can cause issues in the build process along with the support library issues already mentioned.
From /platforms/android/libs/
delete android-support-v4.jar.
It works for me.
Looked around for this solution for much too long now, and I'm not sure if I missed it or just misstyped something, but my Gradle script will not compile. I am migrating to Gradle, and am very new with it. I am very used to using Maven for dependency management, but Gradle seems best me for now. From running this snippet of code:
dependencies {
compile group: 'org.bukkit', name: 'bukkit', version: '1.7.9-R0.1-SNAPSHOT'
compile('io.ibj:MattLib:1.1-SNAPSHOT') {
exclude group: 'de.bananaco'
exclude 'net.milkbowl:vault:1.2.27'
}
compile group: 'net.citizensnpcs', name: 'citizens', version: '2.0.12'
compile group: 'com.sk89q', name: 'worldedit', version: '5.6.1'
compile group: 'com.sk89q', name: 'worldguard', version: '5.9'
compile group: 'net.milkbowl', name: 'vault', version: '1.2.12'
compile fileTree(dir: 'libs', includes: ['*.jar'])
}
NOTE: I do have the java, maven, nexus, shadow, and rebel plugins applied.
When I run my Gradle task, I encounter this error:
Could not find method compile() for arguments [[io.ibj:MattLib:1.1-SNAPSHOT], build_1b5iofu9r9krp7o8mme0dqo9l$_run_closure2_closure8#66fb45e5] on root project 'project'
If I remove the MattLib dependency from my project and reinsert it as
compile 'io.ibj:MattLib:1.1-SNAPSHOT'
The script completes, but I have dependency issues. I read up here:
dependencies {
compile("org.gradle.test.excludes:api:1.0") {
exclude module: 'shared'
}
}
(From Chapter 50 From the Gradle Manual)
that what I have SHOULD work, but I am confused why it doesn't.
gradle --version output:
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.8.0_05 (Oracle Corporation 25.5-b02)
OS: Windows 7 6.1 amd64
Note that the compile, runtime, testCompile, and testRuntime configurations introduced by the Java plugin have been deprecated since Gradle 4.10 (Aug 27, 2018), and were finally removed in Gradle 7.0 (Apr 9, 2021).
The aforementioned configurations should be replaced by implementation, runtimeOnly, testImplementation, and testRuntimeOnly, respectively.
Make sure that you are editing the correct build.gradle file. I received this error when editing android/build.gradle rather than android/app/build.gradle.
compile is a configuration that is usually introduced by a plugin (most likely the java plugin) Have a look at the gradle userguide for details about configurations. For now adding the java plugin on top of your build script should do the trick:
apply plugin:'java'
It should be exclude module: 'net.milkbowl:vault:1.2.27'(add module:) as explained in documentation for DependencyHandler linked from here because ModuleDependency.exclude(java.util.Map) method is used.
In my case, all the compile statements has somehow arranged in a single line. separating them in individual lines has fixed the issue.
In my case the problem was mismatch in the gradle version. I have installed gradle on mac using
brew install gradle
and got the latest gradle which was 7.0
However when I cloned by project repo and executed the gradle taks it failed with below error
* What went wrong:
A problem occurred evaluating root project 'digital-engineering-course'.
> Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter-web, build_bzpgd6h32w4m8umtmgs76ewog$_run_closure3$_closure8#b55ca3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
build.gradle file looked pretty normal to me as it has regular dependencies
dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
It took me a while to understand the problem is mismatch of version. Gradle is not able to find the method compile() because I was using gradle 7.0 in my bash.
And the project was supposed to be ran with gradle 4.8 (Actually gradle wrapper was to be used, but that was breaking for another interesting issue Could not find or load main class org.gradle.wrapper.GradleWrapperMain
(If interested please follow this for details)
The reason for failure is compile is that the compile, runtime, testCompile, and testRuntime configurations introduced by the Java plugin have been deprecated since Gradle 4.10, and were finally removed in Gradle 7.0.
So, to solve the problem I had to install the lower version of gradle. If you want to manage multiple version of gradle use sdkman (earlier known as gvm)
Installation on macOs / linux is as simple as executing below
curl -s "https://get.sdkman.io" | bash
Once done use
sdk list gradle
It will list out all the available versions of the gradle. As per your need install and use. for e.g
sdk install gradle 4.8 (this will choose the 4.8 by default in current shell)
sdk use gradle 4.8 (if already installed, this is suffice to switch between gradle version)
And now the build.gradle was able to compile and execute the task.
Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:3.0.0'
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
app-level build.gradle:
dependencies {
compile 'com.google.android.gms:play-services-auth:9.8.0'
}
In my case I had to remove some files that were created by gradle at some point in my study to make things work. So, cleaning up after messing up and then it ran fine ...
If you experienced this issue in a git project, do git status and remove the unrevisioned files. (For me elasticsearch had a problem with plugins/analysis-icu).
Gradle Version : 5.1.1
Just for the record: I accidentally enabled Offline work under Preferences -> Build,Execution,Deployment -> Gradle -> uncheck Offline Work, but the error message was misleading