我很难让带有 gradle 1.1 的 AS 与 Roboeletric 一起工作。我已经阅读了一些教程并尝试了一些方法,但都没有奏效。
这是我的项目 build.gradle 文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
robo eletric 已下载,这是我的模块 build.gradle:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "br.com.boozeprice"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'org.robolectric'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile project(':androidcore')
compile project(':persistencecore')
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:2.4'
}
gradle 编译,但它看到我在项目中没有库,我不能导入 roboeletric 类,也不能导入它们的注释。
我错过了什么吗?
提前谢谢你。
最佳答案
我所做的就是更改 gradle 文件中的这一行:
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:2.4'
对此:
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.robolectric:robolectric:2.4
现在就像一个魅力
关于Android Studio Gradle 1.1 和 Roboeletric,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29336466/