android-studio - Android Studio构建错误:此版本的Android Studio与所使用的Gradle插件不兼容。尝试禁用即时运行

标签 android-studio gradle version

我今天将Android Studio版本从1.5升级到了2.0,出现了问题。
首先,我收到Gradle版本错误,因此我将Gradle版本从2.10更新到了2.12。

# previous
# distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
# current
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip

Gradle版本错误已消失。
但是现在当我尝试运行我的项目时出现了这个错误:
Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version)

这是我的Project Gradle.build:
// 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:2.0.0'
        classpath 'com.google.gms:google-services:2.1.0-alpha1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的module:app Gradle.build文件。
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'android-apt'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    dexOptions {
        maxProcessCount = 4 // this is the default value
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
}

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { transitive = true; }
    compile('com.twitter.sdk.android:twitter:1.12.1@aar') { transitive = true; }

    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.android.support:cardview-v7:23.3.0'
    compile 'com.android.support:palette-v7:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile 'com.android.support:support-v13:23.3.0'
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.android.gms:play-services-location:8.4.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    compile 'com.paypal.sdk:paypal-android-sdk:2.13.3'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.hotchemi:permissionsdispatcher:2.1.2'
}

apply plugin: 'com.google.gms.google-services'

我从“首选项”中禁用了“即时运行”,但未进行任何更改。
如何解决此错误?
我挣扎了半天。

最佳答案

我在清理项目后删除了build文件夹,现在一切正常。 :D
我不知道为什么会这样,但是预 build 置可能与新的构 build 置冲突。

关于android-studio - Android Studio构建错误:此版本的Android Studio与所使用的Gradle插件不兼容。尝试禁用即时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36709514/

相关文章:

linux - 在 Linux 上确定库的次要版本

java - 如何在列表适配器上显示警报对话框

xml - Android Studio 图形界面中的 ViewFlipper 开关?

android - 如何解决 AAPT2 错误?

android - 尝试导入毕加索库时出现错误

version - 正确使用版本和里程碑的方法

java - Android Studio,无法访问模拟器上数据库文件的数据文件夹

java - 如何使用gradle在类路径中指定外部文件夹内容?

groovy - 如何在gradle中插入属性

python - 无法导入不同Python版本的库