Hi - trying to follow your pattern of sub directories with an existing project. I have tried to replicate what you have almost exactly. Yet when I build I get this error:
- What went wrong:
A problem occurred evaluating project ':UnitTestsRobolectric'.
The 'android' or 'android-library' plugin is required.
It thinks that the main Android application doesn't have the android plugin applied, yet it does! Any idea what I am doing wrong?
The directory structure looks like:
android
build.gradle
settings.gradle
app/
build.gradle
UnitTestsRobolectric
build.gradle
Settings.gradle:
include ':app', 'UnitTestsRobolectric'
My build.gradle in the top most folder has the same settings as yours, except I use build tools 19.0.1.
app/build.gradle has this at top:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
}
apply plugin: 'android'
...
UnitTestsRobolectric/build.gradle has this:
buildscript {
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath "com.novoda:gradle-android-test-plugin:0.9.9-SNAPSHOT"
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:0.4.0'
}
}
apply plugin: 'java'
test.reports.html.enabled = false // just clean up dashboard from not generated reports
test.reports.junitXml.enabled = false // just clean up dashboard from not generated reports
apply plugin: 'android-test'
apply plugin: "jacoco"
apply plugin: 'coveralls'
apply plugin: 'idea'
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
android {
projectUnderTest ':app'
}
I see this code in the plugin source so I know it must have found the gradle file for the app, but I can't explain why it doesn't see the android plugin applied!
public void projectUnderTest(String projectName) {
Project projectUnderTest = project.project(projectName)
def hasAppPlugin = hasAppPlugin(projectUnderTest)
def hasLibraryPlugin = hasLibraryPlugin(projectUnderTest)
if (!hasAppPlugin && !hasLibraryPlugin) {
throw new IllegalStateException("The 'android' or 'android-library' plugin is required.")
pitfall