Search code examples
androidjcenter

getting failed to resolve when adding dependency


I am trying to add an external dependency from jcenter

compile 'com.droidninja:filepicker:2.0.4'

but I keep getting these errors and I can't figure out what is going wrong.

enter image description here

I have seen the same errors come up in lot of projects but nobody seems to know whats going wrong.


Solution

  • The problem is not with the dependency you just added but the Android Support library's dependencies. The latest SDK updates move towards using the remote Google Maven repository instead of downloading everything to be available locally. In order to fix dependency resolution problems follow the Adding Support Libraries guide. Really briefly this is what you have to do:

    1. Open your project's build.gradle (note that this is not the module's file!)
    2. Add the Google Maven repo to the project repositories:

      allprojects {
          repositories {
              jcenter()
              maven {
                  url "https://maven.google.com"
              }
          }
      }
      

    It's also recommended to add the repo to the buildscript block too, so later on the Gradle plugins can be downloaded from there too:

    buildscript {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }