Cannot resolve jitpack dependencies in android studio in the last gradle version
Asked Answered
M

3

10

I get Failed to resolve: com.github.dogecoin:libdohj:v0.15.9 error and I don't know why. I also tried other jitpack dependencies. It works fine in my previous projects.

buildscript {
    ext {
        compose_version = '1.0.2'
    }
    repositories {
        google()
        maven { url "https://jitpack.io" }
        mavenCentral()

    }

    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Molybdic answered 25/9, 2021 at 21:16 Comment(0)
M
18

I added the maven { url "https://jitpack.io" } to the settings.gradle and it fixed the issue.

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url "https://jitpack.io" }

    }
}
rootProject.name = "Crypto World"
include ':app'
Molybdic answered 26/9, 2021 at 23:29 Comment(4)
Also, if your dependencies contain capital letters make them small, for example, implementation 'com.github.SomeName:SomeProject:2.0.1 make it implementation 'com.github.somename.someproject:2.0.1Nomarch
Why isnt this in the official documentation?? I got the same problem and this fixed it for me. THANKS!Grappling
Seriously! This should definitely be in the documentation! Thanks @MolybdicSenecal
This works for me. Besides adding maven { url "jitpack.io" }. I also had to change repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) to repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS).Fernando
C
3

In the new version (7.2) of Gradle some parts is changed, so you need to do like this:

1-Check your gradle version

2- Open the build.gradle(project:---)

3- If like the below code, go to next

plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

4- Open stting.gradle(---)

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

5- Sync Now and finish

Condescension answered 24/3, 2022 at 13:48 Comment(2)
I do not have the following code as in your step 3, Do I have to add it there for each jitpack library I am importing or it was there for you already for some other library? plugins { id 'com.android.application' version '7.1.2' apply false id 'com.android.library' version '7.1.2' apply false }Switzerland
@MayankSinghal, yes, you canCondescension
C
0

Gradle 8.4 dependency use TOML Kotlin

setting.gradle.kts, Here, must register jitpack :

dependencyResolutionManagement {

 repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 

repositories {

    google()

    mavenCentral()

    maven { url = uri("https://jitpack.io") }
 }
}

for more information please see this link https://mcmap.net/q/466304/-unexpected-tokens-use-39-39-to-separate-expressions-on-the-same-line-in-build-gradle-kts

Condescension answered 9/12, 2023 at 7:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.