Could not resolve all dependencies for configuration ':app:debugCompileClasspath - java

This has given me issues since i installed AS it has been having different issues and this is the latest that comes on when I try to build gradle, i have cleaned, updated SDK , restarted but till now no solution, please help.

I also faced this issue before , so i try Clean project then Rebuild project after that i try invalidate caches & Restart and the problem solved.

I solved my problem by removing
maven {
url "https://maven.google.com"
}
in the allprojects { repositeries{ ... } } lines below the buildscript { ... } lines.
Then, I add google() before jcenter() like that :
allprojects {
repositories {
google()
jcenter()
}
...
}

Related

Is Jitpack needed as repository if I am using mavenCentral()?

So I am working on an old project in which I have the following code in the project build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Studio is warning me to use mavenCentral() instead of jcenter() as jcenter is not being updated. So I have change it to the following code:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So my question is, if now I am using mavenCentral() instead of jcenter(), do I have to use the " maven { url "https://jitpack.io" }" line of code or I should´t use it? I mean, the correct code
would be the following instead of the previous code? ->
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Or actually I should use the code line of maven jitpack (maven { url "https://jitpack.io" }") although now I am using mavenCentral() instead of jcenter()?
Or actually I should use the code line of maven jitpack (maven { url "https://jitpack.io" }") although now I am using mavenCentral() instead of jcenter()?
The choice of mavenCentral() versus jcenter() has nothing to do with jitpack.io and whether you should be using it as a repository.
You need a repository to obtain artifacts hosted by that repository. So, for example, you need the google() repository for most of Google's artifacts, such as the com.google.gms:google-services that you are using.
Whether you need jitpack.io will depend on whether you have any dependencies that come from that repository. We have no way of telling whether you do or you do not.
A comment on your question suggests removing it and seeing if your build breaks. That will not work immediately, as Gradle caches downloaded artifacts and usually works off of your cached copy. Your build would break in the future if you try updating the version of some dependency and none of the other repositories host that artifact (at least for that version).
The safest thing to do is to go through all your dependencies (everything listed in a dependencies closure in your project-level and module-level build.gradle files) and identify where they come from. Perhaps add comments to your Gradle files to help you keep track. If you find that none of your dependencies seem to come from jitpack.io, you can remove that repository.

Could not find method dependencyResolutionManagement() for arguments

I'm trying to use a project which my teacher gave to me, but it shows me an error
Settings file '/Users/admin/AndroidStudioProjects/HTTPNetworking/settings.gradle' line: 1
A problem occurred evaluating settings 'HTTPNetworking'.
> Could not find method dependencyResolutionManagement() for arguments [settings_d1xerae4a210x6r7efckrwyki$_run_closure1#580a3803] on settings 'HTTPNetworking' of type org.gradle.initialization.DefaultSettings.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating settings 'HTTPNetworking'.
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method dependencyResolutionManagement() for arguments [settings_d1xerae4a210x6r7efckrwyki$_run_closure1#580a3803] on settings 'HTTPNetworking' of type org.gradle.initialization.DefaultSettings
at settings_d1xerae4a210x6r7efckrwyki.run(/Users/admin/AndroidStudioProjects/HTTPNetworking/settings.gradle:1)
settings.gradle contains:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "HTTP Networking"
include ':app'
What's wrong with it?
in gradle-7.3 and lower method dependencyResolutionManagement have #Incubating annotation. To use this method in your settings.gradle or settings.gradle.kts file you need to add the line:
enableFeaturePreview("VERSION_CATALOGS")
This error can be caused by defining the dependencyResolutionManagement block in a build.gradle file instead of in the settings.gradle (which is where the doco clearly tells you to put it).
Not that I did that or anything.
Feel free to upvote this answer if you also totally did not make that obviously dumb mistake.
This error could be caused due to having an older gradle-version, the issue got resolved for me after i upgraded my gradle version to 7.4.2 for my project
Copy and replace below codes in Top-level build file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and make comment these lines in settings.gardle(:) :
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
Note that Gradle Version better to be 6.6 for Gradle Plugin 4.1.3
Go to gradle/gradle-wrapper.properties and change your distributionUrl
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

ERROR: Could not find com.android.tools.build:gradle:3.2.1

when I want to open or run a project , I get error below :
ERROR: Could not find com.android.tools.build:gradle:3.2.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
Required by:
project :
Open File
and this is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
also by deffault , it contains google repo but the error is there .
I am running on ubuntu 19.1 , and follow the instructions but unfortunetly I can not solve this.
Thanks to Community.
I remember facing such problems, and surprisingly found out that I have network problem!
Here are steps may help you:
- check your system proxy settings.
- then, File -> invalid Cashes/Restart.
clear gradle cache
rm -rf $HOME/.gradle/caches
and resync to download all dependencies
Go Settings/Gradle/Android Studio. Then check "Enable embedded Maven repository". And you're good to go.
Try classpath 'com.android.tools.build:gradle:3.5.3'
also an unrelated addition, Kotlin is -> ext.kotlin_version = '1.3.61'

Gradle Sync Failed to resolve: exifinterface - myhexaville smart image picker

I got this error when I used this dependency 'com.myhexaville:smart-image-picker:1.0.3'
When i commented this dependency, gradle synced successfully.
Please suggest me a proper solution for this problem.
Add Google's Maven repository to your project's build.gradle file :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
If you are using android-studio 3.0 or above use this :
allprojects {
repositories {
jcenter()
google()
}
}

Could not find com.android.tools.build:aapt2 AndroidStudio

getting this error when trying to Build my empty libgdx android studio project ..
Could not find com.android.tools.build:aapt2:3.2.0-alpha16-4748712.
Searched in the following locations:
file:/C:/Users/Noor~.~/android-sdks/extras/m2repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712.pom
file:/C:/Users/Noor~.~/android-sdks/extras/m2repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712-windows.jar
file:/C:/Users/Noor~.~/android-sdks/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712.pom
file:/C:/Users/Noor~.~/android-sdks/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712-windows.jar
file:/C:/Users/Noor~.~/android-sdks/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712.pom
file:/C:/Users/Noor~.~/android-sdks/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712-windows.jar
file:/C:/Users/Noor~.~/.m2/repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712.pom
file:/C:/Users/Noor~.~/.m2/repository/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712-windows.jar
https://repo.maven.apache.org/maven2/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712.pom
https://repo.maven.apache.org/maven2/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712-windows.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712-windows.jar
https://oss.sonatype.org/content/repositories/releases/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712.pom
https://oss.sonatype.org/content/repositories/releases/com/android/tools/build/aapt2/3.2.0-alpha16-4748712/aapt2-3.2.0-alpha16-4748712-windows.jar
Required by:
project :android
You're missing the repositories dependency on Google Maven. You need to edit your main build.gradle file to contain:
buildscript {
repositories {
google() //This!
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha16'
}
}
allprojects {
repositories {
google() // And this!
jcenter()
}
}
So apparently changing the Gradle version fixed the problem for me. The Gradle version that is working is 3.1.3 but I'm not sure why that worked or if it will work for everyone.

Categories