Question

After configure the sonar tools (SonarQube, MySql database and Sonar-runner) I perform an analysis over an Android project without any problem. But after install the Android Plugin for sonar and repeat the analysis, this one fails getting the next error:

INFO  - Preview mode
Load batch settings
User cache: /home/user/.sonar/cache
INFO  - Install plugins
INFO  - Exclude plugins: devcockpit, jira, pdfreport, views, report, buildstability, scmactivity, buildbreaker
INFO  - Create JDBC datasource for jdbc:h2:/home/user/workspace/myAndroidProject/.sonar/.sonartmp/preview1394469024394-0
INFO  - Initializing Hibernate
INFO  - Load project settings
INFO  - Apply project exclusions
INFO  - -------------  Scan myAndroidProject
INFO  - Load module settings
INFO  - Language is forced to java
INFO  - Loading technical debt model...
INFO  - Loading technical debt model done: 424 ms
INFO  - Configure Maven plugins
INFO  - Base dir: /home/user/workspace/myAndroidProject
INFO  - Working dir: /home/user/workspace/myAndroidProject/.sonar
INFO  - Source dirs: /home/user/workspace/myAdnroidProject/src
INFO  - Source encoding: UTF-8, default locale: en_EN
INFO  - Index files
INFO  - Included sources: 
INFO  -   src/**
INFO  - 116 files indexed
WARN  - Accessing the filesystem before the Sensor phase is deprecated and will not be supported in the future. Please update your plugin.
INFO  - Index files
INFO  - Included sources: 
INFO  -   src/**
INFO  - 116 files indexed
WARN  - Accessing the filesystem before the Sensor phase is deprecated and will not be supported in the future. Please update your plugin.
INFO  - Index files
INFO  - Included sources: 
INFO  -   src/**
INFO  - 116 files indexed
INFO  - Quality profile for java: Sonar way
INFO  - Sensor JavaSourceImporter...
INFO  - Sensor JavaSourceImporter done: 49 ms
INFO  - Sensor JavaSquidSensor...
INFO  - Java AST scan...
INFO  - 116 source files to be analyzed
INFO  - 116/116 source files analyzed
INFO  - Java AST scan done: 6693 ms
WARN  - Java bytecode has not been made available to the analyzer. The Depth of Inheritance Tree (DIT) metric, Response for Class (RFC) metric, Number of Children (NOC) metric, Lack of Cohesion (LCOM4) metric, deperecated dependencies metrics, UnusedPrivateMethod rule, RedundantThrowsDeclarationCheck rule, S1160 rule, S1217 rule are disabled.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 18.440s
Final Memory: 12M/357M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: org.sonar.api.resources.Directory cannot be cast to    org.sonar.api.resources.JavaPackage

My sonar-project.properties file is the enxt:

#Required metadata
sonar.projectKey=mKey
sonar.projectName=myAndroidProject
sonar.projectVersion=1.0

# Paths to source directories.
# Paths are relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Do not put the "sonar-project.properties" file in the same directory with the source code.
# (i.e. never set the "sonar.sources" property to ".")
sonar.sources=src

# The value of the property must be the key of the language.
sonar.language=java

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# Analysis mode
sonar.analysis.mode=preview


#Enables the Lint profile to analyze the code using the Lint rules.
#sonar.profile=Android Lint

I'm using the next environment:

  • SonarQube 4.2 RC1
  • Sonar-runner 2.3
  • Database: MySQL
  • Ubuntu 12.04 LTS
  • Java 1.7

I tryed uninstalling the Android plugin but the problem persists. The unique way that I've found to solve it is deleting the database and the user and create them again.

Was it helpful?

Solution

As stated on http://docs.codehaus.org/pages/viewpage.action?pageId=236224987, the Android plugin is not yet compatible with SonarQube 4.2-RC1. See also http://jira.codehaus.org/browse/SONARPLUGINS-3483.

OTHER TIPS

You need to provide the binaries (bytecode .class files) to the sonar executor. Add the following line to your sonar-project.properties

# Path to the class files
sonar.binaries=build\\classes\\main

If the above line doesn't work , then check your binaries actual path and place it in sonar.binaries property

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top