I am trying to add JaCoCo
to my Android
for Sonar Qube
coverage. But upon running the commands ./gradlew jacocoTestReport
I get the following error.
Task :app:testAlphaReleaseUnitTest FAILED
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all files for configuration ':app:jacocoAgent'.
> Could not find org.jacoco:org.jacoco.agent:org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.
Searched in the following locations:
- file:/Users/atif/Library/Android/sdk/extras/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- file:/Users/atif/Library/Android/sdk/extras/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- file:/Users/atif/Library/Android/sdk/extras/google/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- file:/Users/atif/Library/Android/sdk/extras/google/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- file:/Users/atif/Library/Android/sdk/extras/android/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- file:/Users/atif/Library/Android/sdk/extras/android/m2repository/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://dl.google.com/dl/android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://dl.google.com/dl/android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://jcenter.bintray.com/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://maven.fabric.io/public/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://dl.google.com/dl/android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://dl.google.com/dl/android/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
- https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.pom
- https://repo.maven.apache.org/maven2/org/jacoco/org.jacoco.agent/org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated/org.jacoco.agent-org.gradle.testing.jacoco.plugins.JacocoPluginExtension_Decorated.421021a4
Required by:
project :app
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Here are my gradle
files:
project build.gradle
buildscript{
dependencies {
classpath "org.jacoco:org.jacoco.core:0.8.2"
classpath "org.jacoco:org.jacoco.agent:0.8.2"
}
}
plugins {
id "jacoco"
}
App build.gradle:
plugins {
id "com.android.application"
id "jacoco-android"
id "org.sonarqube" version "2.6"
}
android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}
android.testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
jacoco {
toolVersion = "0.8.2"
reportsDir = file("$buildDir/reports/jacoco/")
}
jacocoAndroidUnitTestReport {
csv.enabled false
html.enabled false
xml.enabled true
}
the one is a Gradle plugin, which belongs into the root project's buildscript
dependencies:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath "com.dicedmelon.gradle:jacoco-android:0.1.4"
classpath "com.android.tools.build:gradle:3.2.1"
classpath "org.jacoco:org.jacoco.core:0.8.3"
...
}
}
and the other one is a library, which belongs into the module's Java
dependencies:
apply plugin: "com.android.application"
// apply plugin "jacoco"
apply plugin: "jacoco-android"
...
dependencies {
...
testImplementation "org.jacoco:org.jacoco.agent:0.8.3"
}
the jacoco-android GitHub says nothing about apply plugin "jacoco"
, but it might be required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With