在Android Studio中修复插件版本和同步项目错误

时间:2016-08-03 15:28:40

标签: android android-studio

我目前正在打开此文件Android Studio 2.1,该应用程序是在Android Studio 1.5版中创建的。

Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "abf87974ef3c08e3258fe37c7d5001161385f549"
Fix plugin version and sync project
Open File

导入Android Project时遇到问题,显示错误 按“Fix Plugin”后,它显示“无法更新”。

这是我的build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "app.asharbhutta.com.challanlogin"
        minSdkVersion 13
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    classpath 'com.android.tools.build:gradle:2.1.4'
}

这是gradle-wrapper.properties

#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip

2 个答案:

答案 0 :(得分:2)

我无法在Jcenter / Bintray中找到'com.android.tools.build:gradle:2.1.4'

因此,这个错误是有道理的

  

修复插件版本和同步项目

截至本文,最新的稳定版本为2.1.2

注意:Gradle与Android插件完全分开。 gradle-2.14-bin的版本并不总是与插件编号匹配。

这一切都应该是不言自明的,但为了澄清,这是更正的build.gradle

项目/build.gradle

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

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'

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

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "app.asharbhutta.com.challanlogin"
        minSdkVersion 13
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    // classpath 'com.android.tools.build:gradle:2.1.4' // This shouldn't be here
}

答案 1 :(得分:0)

在Build.gradel中 在Dependencies classpath中以+号结尾,如我所示

classpath'com.android.tools.build:gradle:2.2.0 + '