简体   繁体   中英

Dependency from github is not resolved on gradle, what to do in this case?

I'm trying to import a library from github on my project ( link: https://github.com/justasm/DragLinearLayout )

However, importing on this way:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.jmedeisis:draglinearlayout:1.1.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile files('libs/.jar')
}

on my gadle file doesn't work ( error: Failed to resolve: com.jmedeisis:draglinearlayout:1.1.0 ).

What are my solutions in this case? Is there a clean way to fix it or to import a github project otherwhise?

Gradle downloads binary from maven central repo by default not from github. And this package is not in maven central repo.

You can do those:

  1. This package is in jcenter repository. Click to see the package

Add the following repository in your gradle file

repositories {
maven {
    url  "http://dl.bintray.com/elemyntic/android" 
   }
}
  1. Clone The github project. and build it using gradle build, install it. use mavenLocal() in your repository. And you can use this artifact.

Following EROR's answer, I've succeed with something a bit easier by adding

allprojects { repositories { jcenter() } }

on my gradle file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM