当我使用apply插件时出错:'com.android.library'

时间:2015-08-18 18:11:45

标签: android gradle android-gradle build.gradle

我在android studio中创建了一个普通项目,考虑到教程,我想从该项目创建一个aar文件,但是我收到以下错误:

Gradle: 
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\tec\AndroidStudioProjects\B\B\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':B'.
> Plugin with id 'com.android.library' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
 Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.

我的gradle文件如下:

apply plugin: 'com.android.library'
buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

1 个答案:

答案 0 :(得分:0)

您必须更新脚本:

首先使用最后一个gradle插件。

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

然后更新您的gradle包装器。 在项目中打开此文件:

<Project>/gradle/wrapper/gradle-wrapper.properties

distributionUrl=http\://services.gradle.org/distributions/gradle-2.4-all.zip

最后删除第apply plugin: 'android'