将项目导入Android Studio后出错

时间:2014-02-05 16:46:12

标签: android build gradle android-studio

按照http://developer.android.com/samples/index.html中的步骤,我将repeatingAlarm(http://developer.android.com/samples/repeatingAlarm/project.html)项目导入Android Studio。不幸的是,我收到以下错误:

无法刷新Gradle项目'repeatingAlarm'             该项目使用的是不受支持的Android Gradle插件版本(0.6.3)。             修复插件版本并重新导入项目 快速修复失败             无法在build.gradle文件中找到对Android Gradle插件的任何引用。             请单击链接以执行文本搜索,然后手动更新构建文件。

下面是build.gradle文件:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}

apply plugin: 'android'

dependencies {
    // Add the support lib that is appropriate for SDK 4
    compile "com.android.support:support-v4:18.0.+"
}

// The sample build uses multiple directories to
// keep boilerplate and common code separate from
// the main sample code.
List<String> dirs = [
        'main',     // main sample code; look here for the interesting stuff.
        'common',   // components that are reused by multiple samples
        'template'] // boilerplate code that is generated by the sample template process

android {
    compileSdkVersion 19
    buildToolsVersion "18.0.1"

    sourceSets {
        main {
            dirs.each { dir ->
                java.srcDirs "src/${dir}/java"
                res.srcDirs "src/${dir}/res"
            }
        }
        instrumentTest.setRoot('tests')
        instrumentTest.java.srcDirs = ['tests/src']
    }
}

这里的IDE告诉我这样的错误: enter image description here 我该怎么办?

1 个答案:

答案 0 :(得分:2)

更改buildToolsVersion&#34; 18.0.1&#34;最新版本如&#34; 20.0.1&#34;,它将起作用:)