I trying to set a sonar analysis on an android project
The analysis is done with version 4.3 of sonarQube trough sonar-runner, android-plugin install, ANDROID_HOME env variable is set on /path/to/android/sdk, the build is done with ant without any problems
the execution run well but i have tons of error messages :
14:23:46.563 ERROR - Class not found: android.content.UriMatcher
14:23:46.563 ERROR - Class not found: android.net.Uri
14:23:46.563 ERROR - Class not found: android.database.sqlite.SQLiteDatabase
14:23:46.568 ERROR - Class not found: android.provider.BaseColumns
14:23:46.757 ERROR - Class not found: android.net.Uri
14:23:46.829 ERROR - Class not found: android.content.ContentProvider
14:23:46.829 ERROR - Class not found: android.net.Uri
14:23:46.830 ERROR - Class not found: android.database.sqlite.SQLiteDatabase
14:23:46.830 ERROR - Class not found: android.content.Context
...
My sonar-project.propeties :
sonar.projectKey=Client-Project
sonar.projectName=Client-Project
sonar.projectVersion=2.0
sonar.sources=src
sonar.binaries=bin/classes
sonar.librairies=bin/dexedLibs,usr/local/android-sdk-linux
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.profile=Android Lint
How to set Sonar to find these android classes ?
To get rid of these errors, add android.jar location directly to sonar.libraries
:
sonar.libraries=libs/*.jar,/usr/local/opt/android-sdk/platforms/android-18/android.jar
Two obvious drawbacks with this:
Building up on Mikko's answer, note that you don't really have to manually keep the setting in sync with your targetSdk. You can get it from gradle as in:
def androidJarPath;
afterEvaluate {
def rootDir = project.rootDir
def localProperties = new File(rootDir, "local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
androidJarPath = sdkDir + "/platforms/" + android.compileSdkVersion + "/android.jar"
}
}
sonarqube {
properties {
property "sonar.java.libraries", androidJarPath
...
}
}
Cheers!
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