Android Studio构建错误:这个版本的Android Studio与使用的Gradle插件不兼容。尝试禁用即时运行

时间:2021-10-13 07:00:21

I upgraded Android Studio version from 1.5 to 2.0 today and something has gone wrong.
First I got Gradle version error, so I updated Gradle version from 2.10 to 2.12.

我今天把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 version error has disappeared.
But now I have this error when I try to run my project:

版本错误已经消失。但是现在我尝试运行我的项目时出现了这个错误:

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)


This is my 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
}


And this is my module:app Gradle.build file.

这是我的模块:app Gradle。构建文件。

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'


I disabled Instant Run from Preferences but nothing changed.
How can I resolve this error?
I'm struggling for half days.

我从首选项中禁用了即时运行,但没有任何改变。如何解决这个错误?我挣扎了半天。

8 个解决方案

#1


26  

I deleted the build folder after cleaning project, and everything is just working fine now. :D
I don't know exactly why this happen, but maybe pre-built setting conflicted with new build setting.

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

#2


10  

I faced this issue after updating Android Studio to 2.3! I didn't delete any file!

在更新Android Studio到2.3之后,我面临这个问题!我没有删除任何文件!

Just cleaned the project and it worked!

刚刚清理完这个项目,它就成功了!

#3


8  

On Android 2.0 and above.

在Android 2.0和以上。

1 - In Settings -> Build, Execution, Deployment option -> Instant Run

1 -在设置->构建,执行,部署选项->即时运行。

2 - Clear Enable instant run to hot swap code

2 -清晰的启用即时运行到热交换代码。

3 - Clean project

3 -清洁项目

p/s : It should totally work.

p/s:完全可以。

#4


4  

I'm Using Android Studio 2.2, and for me... Clean the project and delete build folder solved the issue.

我正在使用Android Studio 2.2,对我来说…清理项目和删除构建文件夹解决了问题。

I have just one different with you. I putted on build.gradle. classpath 'com.android.tools.build:gradle:+'

我和你有一点不同。我排上build.gradle。类路径的com.android.tools.build:gradle:+

#5


2  

Make sure that Android Studio up to date!!

确保Android Studio最新!!

AndroidStudio > Help > Check For Updates ...

AndroidStudio >帮助>检查更新…

#6


1  

Plugin version  Required Gradle version


1.0.0 - 1.1.3   2.2.1 - 2.3

1.2.0 - 1.3.1   2.2.1 - 2.9

1.5.0   2.2.1 - 2.13

2.0.0 - 2.1.2   2.10 - 2.13

2.1.3 - 2.2.3   2.14.1+

2.3.0+  3.3+

e.g. set the Gradle version to 3.3 in the gradle-wrapper.properties file.

例如,将Gradle版本设置为3。属性文件。

...
distributionUrl = https\://services.gradle.org/distributions/gradle-3.3-all.zip
...

set the Android plugin for Gradle to version 2.3.0 from the build.gradle file:

将Android插件从构建版本中设置为2.3.0版本。gradle文件:

buildscript {
  ...
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
  }
}

Also you have to make sure there are no *es by checking: File - > Project Structure - > (click on)Project

另外,你还要确保没有冲突:文件- >项目结构- >(点击)项目。

#7


0  

  1. go to Preferences and find Gradle
  2. 转到首选项,然后找到Gradle。
  3. select "Use default Gradle wrapper"
  4. 选择“使用默认等级包装”
  5. Build - Clean Project
  6. 构建——清洁项目

and it will update the Gradle file for you automatically and run in a while.

它会自动更新您的Gradle文件并运行一段时间。

#8


0  

Clearing the project (Build -> Clean Project) is the right thing to do in this case.

在这种情况下,清理项目(Build -> Clean project)是正确的事情。

#1


26  

I deleted the build folder after cleaning project, and everything is just working fine now. :D
I don't know exactly why this happen, but maybe pre-built setting conflicted with new build setting.

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

#2


10  

I faced this issue after updating Android Studio to 2.3! I didn't delete any file!

在更新Android Studio到2.3之后,我面临这个问题!我没有删除任何文件!

Just cleaned the project and it worked!

刚刚清理完这个项目,它就成功了!

#3


8  

On Android 2.0 and above.

在Android 2.0和以上。

1 - In Settings -> Build, Execution, Deployment option -> Instant Run

1 -在设置->构建,执行,部署选项->即时运行。

2 - Clear Enable instant run to hot swap code

2 -清晰的启用即时运行到热交换代码。

3 - Clean project

3 -清洁项目

p/s : It should totally work.

p/s:完全可以。

#4


4  

I'm Using Android Studio 2.2, and for me... Clean the project and delete build folder solved the issue.

我正在使用Android Studio 2.2,对我来说…清理项目和删除构建文件夹解决了问题。

I have just one different with you. I putted on build.gradle. classpath 'com.android.tools.build:gradle:+'

我和你有一点不同。我排上build.gradle。类路径的com.android.tools.build:gradle:+

#5


2  

Make sure that Android Studio up to date!!

确保Android Studio最新!!

AndroidStudio > Help > Check For Updates ...

AndroidStudio >帮助>检查更新…

#6


1  

Plugin version  Required Gradle version


1.0.0 - 1.1.3   2.2.1 - 2.3

1.2.0 - 1.3.1   2.2.1 - 2.9

1.5.0   2.2.1 - 2.13

2.0.0 - 2.1.2   2.10 - 2.13

2.1.3 - 2.2.3   2.14.1+

2.3.0+  3.3+

e.g. set the Gradle version to 3.3 in the gradle-wrapper.properties file.

例如,将Gradle版本设置为3。属性文件。

...
distributionUrl = https\://services.gradle.org/distributions/gradle-3.3-all.zip
...

set the Android plugin for Gradle to version 2.3.0 from the build.gradle file:

将Android插件从构建版本中设置为2.3.0版本。gradle文件:

buildscript {
  ...
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
  }
}

Also you have to make sure there are no *es by checking: File - > Project Structure - > (click on)Project

另外,你还要确保没有冲突:文件- >项目结构- >(点击)项目。

#7


0  

  1. go to Preferences and find Gradle
  2. 转到首选项,然后找到Gradle。
  3. select "Use default Gradle wrapper"
  4. 选择“使用默认等级包装”
  5. Build - Clean Project
  6. 构建——清洁项目

and it will update the Gradle file for you automatically and run in a while.

它会自动更新您的Gradle文件并运行一段时间。

#8


0  

Clearing the project (Build -> Clean Project) is the right thing to do in this case.

在这种情况下,清理项目(Build -> Clean project)是正确的事情。