Android Studio Build Error:此版本的Android Studio与使用的Gradle插件不兼容.尝试禁用即时运行

Suh*_*Lee 17 version gradle android-studio

我今天将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
Run Code Online (Sandbox Code Playgroud)

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)
Run Code Online (Sandbox Code Playgroud)


这是我的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
}
Run Code Online (Sandbox Code Playgroud)


这是我的模块: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'
Run Code Online (Sandbox Code Playgroud)


我从首选项中禁用了"即时运行"但未更改.
我该如何解决这个错误?
我挣扎了半天.

Suh*_*Lee 26

我在清理项目后删除了build文件夹,现在一切正常.:D
我不确切知道为什么会发生这种情况,但可能预建的设置与新的构建设置相冲突.


Dar*_*shn 10

将Android Studio更新为2.3后我遇到了这个问题!我没有删除任何文件!

刚刚清理了项目,它工作正常!


Huy*_*wer 8

在Android 2.0及更高版本上.

1 - 在Settings- > Build, Execution, Deployment选项 - >Instant Run

2 - 清除 Enable instant run to hot swap code

3 - 清洁项目

p/s:应该完全奏效.

  • 禁用即时运行不是*修复*. (4认同)