无法解析配置的所有依赖项':ZBarScannerActivityLib:classpath'

时间:2016-11-03 16:08:18

标签: android maven gradle pom.xml zbar

从ZBarScannerActivityLib库项目的命令行执行 gradle build 时出现此错误。 详细错误消息如下

*配置项目':ZBarScannerActivityLib'时出现问题。

  

无法解析配置的所有依赖项':ZBarScannerActivityLib:classpath'。   找不到com.android.tools.build:gradle:2.2.2。        在以下位置搜索:            https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom            https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar        要求:            LDDAndroid:ZBarScannerActivityLib:未指定*

ZBarScannerActivityLib的build.gradle文件

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
    }
}
apply plugin: 'android-library'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDir 'libs'
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

1 个答案:

答案 0 :(得分:1)

 classpath 'com.android.tools.build:gradle:2.1.3'