Rosendo Ropher
Rosendo Ropher

Reputation: 498

Analyze Android Studio (Gradle) project with Sonarqube

I'am trying to analize an Android Studio project with Sonarqube.

I have the sonarqube running on my PC, the project is in a SVN repository. When I run the command gradle sonarqube this is the output

For all classes in the porject (src/ folder) the message is

Class 'abc' is not accesible through the ClassLoader

This is my actual configuration, the root project gradle file

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1"
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

The app gradle file

apply plugin: 'com.android.application'
apply plugin: "org.sonarqube"

... android config
... dependencies etc ...
sonarqube {
    properties {
        property 'sonar.projectName', 'Material Design Sample'
        property 'sonar.working.directory', '$project.buildDir/sonar'
        property 'sonar.projectVersion', '1'
        property 'sonar.scm.provider', 'svn'
        property 'sonar.sources', 'src/main/java'
        property 'sonar.language', 'java'
        property 'sonar.sourceEncoding', 'UTF-8'
        property 'sonar.java.binaries', 'build'
        property 'sonar.java.libraries', 'libs/*.jar'
        property 'sonar.java.test.binaries', 'build'
        property 'sonar.java.test.libraries', 'libs/*.jar'
    }
}

I'm working with Sonar 5.5, Gradle 2.3 and Java 7, I had been reading this documentation

I had been reading many FAQ, Q&A sites but I can't fix my problem.

Upvotes: 4

Views: 7778

Answers (1)

Android Developer
Android Developer

Reputation: 9643

As per build script for new, incubating, plugin mechanism introduced in Gradle 2.1:

Remove

classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1"

Apply sonarqube plugin to app module gradle file of your project like this

plugins {
    id "org.sonarqube" version "2.2.1"
}

After building or syncing project,open Command Prompt and navigate to app module directory where your gradle file is located.

Execute gradle sonarqube and wait until the build is completed.

Below is the link of post on my blog which gives complete detailed explanation of integrating sonarqube in Android with sonarqube scanner.

Integrating and Understanding SonarQube in Android

Upvotes: 0

Related Questions