使用Gradle构建Android Studio项目

时间:2014-12-09 08:30:43

标签: android gradle android-studio

我正在尝试通过在工作室中导入来构建Android Studio应用程序,但我有一个问题。

我的Android Studio版本(测试版)0.8.14

在我的gradle-wrapper.properties文件distributionUrl中:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

我需要在build.gradle文件夹的app文件夹中添加以下更改 构建此应用程序。

修改过的文件:

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

}
apply plugin: 'android'

----- Other things -----

原始文件:

apply plugin: 'com.android.application'

----- Other things -----

如果我没有添加buildscript更改,则会收到错误Error:(1, 0) Plugin with id 'com.android.application' not found 为什么我需要添加buildscript部分,以使其编译。

更新

是的我有顶级build.gradle文件,其中包含以下行:

// Top-level build file where you can add configuration options common to all   
sub-projects/modules.

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

0 个答案:

没有答案