User
User

Reputation: 53

Android studio couldn't load JitPack library

I am using one library from github to create a tableview but the tableview is showing an error in my project. I have added their implementation in my gradle file.

Library Link : https://github.com/evrencoskun/TableView

XML code

Dependancies

Top level gradle file

Upvotes: 1

Views: 1689

Answers (1)

Shubham Panchal
Shubham Panchal

Reputation: 4289

JitPack seems to be published on jcenter whose use is now deprecated in Android. All non-Google artifacts now come from mavenCentral. The solution isn't documented in the official JitPack docs, but we can use the dependencyResolutionManagement block, like,

// settings.gradle
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 = "App"
include ':app'

The code will enforce settings repositories on the repositories mentioned in build.gradle. For repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) the official docs say,

If, for some reason, a project or a plugin declares a repository in a project, Gradle would warn you. You can however make it fail the build if you want to enforce that only settings repositories are used

Refer to this answer along with this one.

Upvotes: 2

Related Questions