gpt4 book ai didi

Android studio 1.1.0 无法设置 Robolectric

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:36:55 26 4
gpt4 key购买 nike

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

项目.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()
}
}

应用程序.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

关于Android studio 1.1.0 无法设置 Robolectric,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29714750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com