首页 > 代码库 > gradle编译出错:Execution failed for task ':app:compileTestDebugJava'.

gradle编译出错:Execution failed for task ':app:compileTestDebugJava'.

今天更新了android studio,从0.5.3升级到0.6.1版本,结果在IDE中编译时没有问题,但是在命令行时编译就会出现以下错误:

:app:compileTestDebugJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileTestDebugJava'.
> No signature of method: com.android.build.gradle.AppPlugin.getRuntimeJarList() is applicable for argument types: () values: []

我随着更新gradle到1.12,问题同样存在。

貌似是gradle更新之后,里面的单元测试插件未更新。各种谷歌,找到了这个地址:https://github.com/robolectric/robolectric-gradle-plugin。于是换用原来的插件为这一个,修改如下(参照该地址的README文件):将以下内容:

    dependencies {
        classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
    }
修改为:
    dependencies {
        classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+'
    }

同时把apply plugin: ‘android-test‘ 修改为apply plugin: ‘robolectric‘


再运行Gradle clean build,成功。