Unable to import project into android studio

I am trying to use this library

I added

compile 'net.rdrei.android.dirchooser:library: 2.0@aar ' 

depending on.

My top level build file

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' } } allprojects { repositories { mavenCentral() } } 

And this gives me the error "failed to update the gradle project" with reference to the project I'm trying to import.

+6
source share
4 answers

This library is not located on central Maven as aar.

Check here:

http://search.maven.org/#search%7Cga%7C1%7Cnet.rdrei.android.dirchooser is an apklib format.

I checked the snapshot repository and here you can find this library.

https://oss.sonatype.org/content/repositories/snapshots/net/rdrei/android/dirchooser/library/

To use repo binding you have to change your script:

 repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } 

Then add a depencency parameter like

 compile 'net.rdrei.android.dirchooser:library:2.1-SNAPSHOT' 
+13
source

The answer provided by @unify @GabrieleMariotti and @AndyJoiner is correct. However, this is confused, since we have two gradle files - the gradle project level and the internal gradle (where you write your dependencies). The solution is to add the code suggested by @AndyJoiner inside the internal gradle .

Since I was confused as to where to add the code, which took me an hour to understand, I do not want this to happen to others. So, I am sending my both gradle files.

Gradle project level

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.0.0' } } allprojects { repositories { jcenter() } } 

Inner gradle

 apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.itcse.materialdesignsearchviewlikegoogleplay" minSdkVersion 15 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } // Add the code for repositories here repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url 'http://guardian.github.com/maven/repo-releases' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' // Add the dependencies here compile 'com.quinny898.library.persistentsearch:library: 1.0.0-SNAPSHOT@aar ' } 

Hope this helps others in the future.

+3
source

This worked for me:

 repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } 

Here you can find the repository https://oss.sonatype.org/#nexus-search;quick~dirchooser

+1
source

Having tried Gabriele's answer and digging a little more, it worked for me

 repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url 'http://guardian.github.com/maven/repo-releases' } } dependencies { compile 'net.rdrei.android.dirchooser:library: 2.2-SNAPSHOT@aar ' } 
+1
source

All Articles