Use Cobertura with android plugin

when my gradle use cobertura plugin with android plugin. on my command shows me some message as BUILD FAILED.
like follow.

> gradle build

Picked up _JAVA_OPTIONS:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'AndroidReferenceApp'.
> The 'java' plugin has been applied, but it is not compatible with the Android

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.


Total time: 1 mins 13.044 secs

and this is my build.gradle

    buildscript {
    repositories {
		maven {
			url ""
    dependencies {
        classpath ''
		classpath "net.saliman:gradle-cobertura-plugin:2.2.8"
apply plugin: "net.saliman.cobertura"
apply plugin: 'android'

dependencies {

    compile fileTree(dir: 'libs', include: '*.jar')
	compile files('libs/android-support-v4.jar')

android {
    compileSdkVersion 21
    buildToolsVersion "21.0.1"
	lintOptions {
		abortOnError false
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['rs']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']

        // Move the tests to tests/java, tests/res, etc...

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.

could anyone let me know what i have problem? or could you provide me some sample configuration with android and cobertura?

The cobertura plugin is attempting to add the ‘java’ plugin, which is incompatible with the android plugin. The authors of the cobertura plugin will have to update their plugin to be compatible with Android projects.

Issue #82 has been created against the Cobertura plugin for this problem.

I’m not sure how to proceed with a fix though. The plugin currently assumes that certain things exist such as a test task and a sourceSets.main property. When I apply the android plugin without the java plugin, these things don’t appear to be present.

If you’ve got ideas, please follow up in the Gradle plugin issue.


Steve Saliman