简体   繁体   中英

ClassCastException: ApiVersionImpl cannot be cast to java.lang.Integer

I have android + gradle project. The following exception appears when I try to start application:

'ClassCastException: com.android.build.gradle.internal.model.ApiVersionImpl cannot be cast to java.lang.Integer: com.android.build.gradle.internal.model.ApiVersionImpl cannot be cast to java.lang.Integer'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
    }
}

apply plugin: 'android'
apply plugin: 'android-apt'

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    compile files('libs/android-support-v4.jar')
    compile 'org.androidannotations:androidannotations-api:3.0.1'
    apt 'org.androidannotations:androidannotations:3.0.1'
}

android {
    compileSdkVersion 15
    buildToolsVersion '19.1'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 15
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
}

There is bug report open to google. For Intellij 13.1.4 it is still failure.

Rolling back build tools version to 1.10.+ can help.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
    }
}

I realized that IDEA Intellij 14 EAP has no such problem and support Android L as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM