5

Recently, I updated my Android Studio to Bumblebee(stable version) that was released around 2 weeks back. The structure of the build.gradle(root-level) file seems to have changed a lot since the last version.

I am facing issue in adding dependencies in the root-level build.gradle file.

Here is what I want to add.enter image description here

in the build.gradle file

enter image description here

Simba-97
  • 135
  • 3
  • 6

4 Answers4

14

settings.gradle instead of build.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
      // ...
        maven { url 'https://jitpack.io' }
    }
}

this way you dont need to use the build.gradle instead use the settings.gradle, these way it worked for me in Android Studio Bumblebee

1234567
  • 2,226
  • 4
  • 24
  • 69
1

I think you should use buildscript instead of allprojects. Found question in stackoverflow which explain difference between buildscript and allprojects What's the difference between buildscript and allprojects in build.gradle? So I would suggest to try:

buildscript {
    repositories {
        ...
    }
}

Hopefully this will help :)

Courtesy
  • 198
  • 1
  • 9
  • Yeah, it helped but the problem was in the dependency itself, what I was trying to use was not supported for AndroidX but nevertheless thank you for your help :) – Simba-97 Feb 13 '22 at 10:42
1
  1. Keep your buildscript repositories at the top of your project-level build.gradle file:
buildscript {
    // ...
    repositories {
        // HERE
    }
}

plugins {
    // ...
}
  1. Move your allprojects repositories to settings.gradle file:
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        // HERE
    }
}
Ashwin
  • 53
  • 5
0
**1.instead of openping build.gradle just open the setting.gradle and just the stuff there..it will working properly**


pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()

        //..... just add here
        maven { url 'https://jitpack.io' }
    }
}