Android SonarQube


sonarqube is static code analysis for several languages.

How do we use?

We can use both local and serverside. A developer check codes on local and fix problems. Prepare CI and check code periodically.
And we can use it with CI such as jenkins.

Set up for database

To use sonarqube, we need to prepare database.
Sonarqube covers several Database, oracle, mysql, postresql, SQLServer …
In this time, let’s use mysql.


  • Install mysql
  • Create database for sonarqube

Installation part is skip.
Let’s create database named ‘sonar'(Any name is O.K., it’s just settings)

create database sonar

And setup username and password if you want

Install SonarQube

Please access SonarQube page, and download zip file according to your OS.
I download windows version 4.5.7, download and unzip.(Finished)
You can see directories under unzip directory(bin, conf, data, etc…)
To start sonarqube by command, see sonarqube/windows-x86-64


Start sonarqube and work with localhost:9000

If you didn’t setup database, you cannot see specific data

Android Studio gradle plugin

Edit build.gradle for Project and App

buildscript {
    repositories {

        maven {
            url ""    // ADD
    dependencies {
        classpath ''
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1"  // ADD

Add repository settins and dependencies

apply plugin: "org.sonarqube"

sonarqube  {
    properties  {
        property "", "http://localhost:9000"
        property "sonar.jdbc.url", "jdbc:mysql://localhost/sonar"
        property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
        property "sonar.jdbc.username", "sonar"
        property "sonar.jdbc.password", "sonar"
        property "sonar.language", "java"
        property "sonar.sources", "src/main/java"

Set parameters for Android, database setting should be your database environment.