Reputation: 4376
I want to use the maven library in the android studio project. in the library documentation, they mention adding like this,
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
But in the new android studio build.gradle
file looks like this
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So, how do I want to add this library repository, Thank you
Upvotes: 9
Views: 11620
Reputation: 171
I recently had a lot of confusion with this, but I was able to solve it this way, I just added Maven in Settings.gradle, when I added twice this caused me conflicts, but when I tried just adding once then it worked correctly.
I am using Android Studio Dolphin 2021.3.1.
Upvotes: 2
Reputation: 111
If you want to add the maven url to settings.gradle.kt file Add like this:
maven {url = uri("https://www.jitpack.io" ) }
This line worked for me on 3. October. 2023
Upvotes: 8
Reputation: 445
Referring to answer from Prasath, I would simplify the answer. In old gradle structure you have a line in Project build.gradle:
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // this is your line
}
In new gradle structure you have to add a line in setting.gradle like this:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // // this is your line
}
}
You do not have to add the line in pluginManagement{} section in settings.gradle.
Upvotes: 6
Reputation: 4376
In the latest Android Studio Bumblebee(2021.1.1) version, if you see it in build.gradle(Project)
the new structure looks like this
build.gradle(Project)
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In order to use the other libraries like maven
, you have to go to the settings.gradle
and you have to the maven link like below
settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url 'https://jitpack.io' } // add like this
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // add like this
}
}
rootProject.name = "your project name here"
include ':app'
finally add the library in to your
Build.gradle(module)
dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
Upvotes: 9