android-analyzer
android-analyzer copied to clipboard
Code coverage not showing on Sonar
Code coverage not showing on Sonar : android { compileSdkVersion 28 buildToolsVersion "28.0.3" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
defaultConfig {
applicationId "com.oxyliom.oxyliomotp"
minSdkVersion 20
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_static'
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}
}
}
sourceSets {
main {
// let gradle pack the shared library into apk
jniLibs.srcDirs = ['../distribution/gperf/lib']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
externalNativeBuild {
cmake {
version '3.10.2'
path 'src/main/cpp/CMakeLists.txt'
}
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
}
androidAnalyzer { applicationId = 'com.oxyliom.oxyliomotp' projectName = 'Oxyliom OTP' projectVersion = '1.0' unitTestCoverage = true packageName = 'com.oxyliom.oxyliomotp' buildVariant = 'debug'
}
Interesting.
- Double-check your
packageName
argument, maybe it is different from your app id. - If you are using Robolectic, make sure to add
android.enableUnitTestBinaryResources=true
to yourgradle.properties
file. - The plugin does not support code coverage of instrumented tests, only unit tests.
Could you check the above points and get back to me, please? Also, a screenshot of the Sonarqube web interface would be helpful.
- same packageName and app id .
i can find the androidAnalyzerJacoco folder in my project.
please find below the screenshoot of my coverage report and Sonarqube web interface


Based on everything you provided, the coverage should be there.
Since the correct gets generated, my assumption is that the report is not sent to Sonarqube. This can potentially mean that the plugin resolved the report's path incorrectly.
I am looking into what might have caused it. In the meantime, could you set useDefaultExclusions = false
, just in case all your >0% coverage is for excluded classes?
I set useDefaultExclusions = false
, but style the same bug just the number of new line to cover become duplicate.
i think the problem is that the plugin resolved the report's path incorrectly.
I have the same problem. Has anyone found a solution?
I have the same problem. Has anyone found a solution?
no, in android studio i get 60% covered but in sonar show me 0% .
Facing Same Problem Any Help so Far?
Hi, i m solved using directly Sonar and not Android Analyzer. Add conf in task gradle sonar:
property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/jacocoProdDebugCoverage/jacocoProdDebugCoverage.xml"
Change dir for you and run.
I am also having this Problem :-(
I am also having this Problem :-(
Try do what i did. Work for me