android gradle build无法添加第三方库

时间:2014-06-16 04:40:56

标签: android gradle android-gradle build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.11.+'
    }
}

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "uz.dev.app.todak"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v13:19.+'
}

我想在我的项目中添加这个库。 https://github.com/astuetz/PagerSlidingTabStrip

dependencies {
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}

但错误!

Error:com.astuetz:pagerslidingtabstrip:1.0.1
<a href="searchInBuildFiles">Search in build.gradle files</a>

Occurrences of 'com.astuetz:pagerslidingtabstrip:1.0.1' in Project with mask 'build.gradle'

1 个答案:

答案 0 :(得分:0)

此库可在mavenCentral获取。要从mavenCentral解析依赖关系,您需要声明一个存储库。 (buildscript块中的repository部分仅用于解析buildscript依赖项):

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.11.+'
    }
}

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "uz.dev.app.todak"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories{
    mavenCentral()
}

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
        compile 'com.android.support:support-v13:19.+'
}