Can't import project to android studio

后端 未结 4 1686
抹茶落季
抹茶落季 2021-01-13 01:05

I\'m trying to use this library

I\'ve added

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

to dependecies.

My top

4条回答
  •  爱一瞬间的悲伤
    2021-01-13 01:20

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

    Since I was confused as to where to add the code, which took me an hour to figure out, I don't want it to happen to others. So, I am posting my both gradle files.

    Project Level Gradle

    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 help others in future.

提交回复
热议问题