I used to be able to use roboelectric with gradle just fine until recently. I keep getting an error Error:(6, 17) error: package org.junit does not exist
. I'm not quite sure and have dug into this quite a bit.
Below is my project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
}
}
Below is my app build.gradle:
repositories {
mavenCentral()
jcenter()
}
apply plugin: 'com.android.application'
android {
...
sourceSets {
androidTest.setRoot('src/test')
}
}
dependencies {
...
// Testing
compile project(':core')
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'junit:junit:4.+'
testCompile 'org.easytesting:fest:1.0.16'
testCompile 'com.squareup:fest-android:1.0.8'
}
my core project build.gradle:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:2.4'
}
I have read the below regarding this and nothing here has worked for me:
https://www.bignerdranch.com/blog/all-in-together-android-studio-gradle-and-robolectric/ - the android studio plugin that is to be used crashes on newer android studio versions.
https://www.bignerdranch.com/blog/triumph-android-studio-1-2-sneaks-in-full-testing-support/ - this simply doesn't solve the problem. It cannot find org.junit.
Can anybody point me in the right direction for this? Why is it not able to detect org.junit
from the build.gradle
?