sun*_*hun 4 android unit-testing robolectric
我在Android 1.1.0之前使用过Robolectric但在更新之后我再也无法使用它了.我用Google搜索并尝试了一些解决方案,但没有一个有效.这是我目前的设置:
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()
}
}
Run Code Online (Sandbox Code Playgroud)
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'
}
Run Code Online (Sandbox Code Playgroud)
当我尝试构建项目时,它给出了如下错误:
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
Run Code Online (Sandbox Code Playgroud)
当然,我安装了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
| 归档时间: |
|
| 查看次数: |
1006 次 |
| 最近记录: |