Android studio 1.1.0 无法设置 Robolectric

Android studio 1.1.0 cannot setup Robolectric

我在Android 1.1.0之前用过Robolectric,但是更新后就不能用了。我用谷歌搜索并尝试了一些解决方案,但其中 none 有效。 这是我当前的设置:

project.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
        classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.1.1'

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

allprojects {
    repositories {
        jcenter()
    }
}

app.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "my_package_name"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

apply plugin: 'android-unit-test'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:21.0.3'
    testCompile 'org.easytesting:fest:1.0.16'
    testCompile 'junit:junit:4.10'
    testCompile 'org.robolectric:robolectric:2.4'
    testCompile 'com.squareup:fest-android:1.0.8'
}

当我尝试构建项目时,出现如下错误:

Error:(22) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'android-unit-test']
   > No such property: bootClasspath for class: com.android.build.gradle.AppPlugin

当然,我安装了 android-unit-test 插件,然后删除并重新安装,但没有成功。

您的回答将不胜感激。

坏消息:自 Android 插件 1.1.0 以来,插件 com.github.jcandksolutions.gradle:android-unit-test:2.1.1 已被删除。另见 https://github.com/JCAndKSolutions/android-unit-test#deprecation-notice

好消息:您不再需要 robolectric 的插件。只需删除 apply plugin: 'android-unit-test',一切都应该像以前一样工作。

这里是一个示例项目设置https://github.com/nenick/AndroidStudioAndRobolectric