skip to Main Content

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?

5

Answers


  1. 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")
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
  5. Go to gradle/gradle-wrapper.properties and change your distributionUrl

    distributionUrl=https://services.gradle.org/distributions/gradle-7.4-bin.zip
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search