1

I am trying to integrate sonarqube to my android project. below is my root build.gradle

Im trying to follow what is mentioned here - http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle and Analyzing Android Project with Lint and SonarQube

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

sonarqube {
    properties {
        property "sonar.profile", "Android Lint"
        property "sonar.sources", "./src/main/java"
        property 'sonar.host.url', '<sonar_qube_server_url>'
        property 'sonar.sourceEncoding', 'UTF-8'
        property 'sonar.import_unknown_files', true
        property 'sonar.android.lint.report', 'build/outputs/lint-results.xml'
    }
}

I run below from project root -

./gradlew sonarqube

Below error is being thrown -

Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19-1' (Expected '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19')
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19-1' (Expected '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19')
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19-1' (Expected '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19')
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19-1' (Expected '/Users/<username>/Library/Android/sdk/add-ons/addon-google_apis-google-19')
Incremental java compilation is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
com/android/build/gradle/api/BaseVariant
> com.android.build.gradle.api.BaseVariant

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Please help in understanding what is going wrong here.

Community
  • 1
  • 1
iOSTech
  • 77
  • 1
  • 8

2 Answers2

1

Was able to figure out the issue. I am using 2.2v of sonarqube plugin for gradle which is not compatible to my gradle version. Changed the plugin version to 2.0v & started working with out any issues.

iOSTech
  • 77
  • 1
  • 8
0

try using this file:

sonarqube.gradle:

apply plugin: "org.sonarqube"

sonarqube {

    properties {

        property "sonar.projectName", "appa"

        property "sonar.projectKey", "appa_app"

        property "sonar.projectVersion", "1.0"

        property "sonar.analysis.mode", "publish"

        property "sonar.language", "java"

        property 'sonar.sourceEncoding', "UTF-8"

        property "sonar.sources", "./src/main"

        //property "sonar.exclusions", "**/*Entity.java"

      //  property "sonar.exclusions", "src/main/java/com/apparkb/model/**, **/*Entity.java"

        property "sonar.host.url", "http://192.168.21.33:9000"

        property "sonar.login", "admin"

        property "sonar.profile", "testlint"

        property 'sonar.import_unknown_files', true

        property "sonar.android.lint.report", "./build/outputs/lint-results-debug.xml"

        property "sonar.password", "admin"

        property "sonar.java.binaries", "build/"



    }
}

alter the properties according to your needs and use your quality profile

And in your projects build.gradle add the maven plugin and add the dependencies as shown below

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

after that run

./gradlew sonarqube 

this worked for me,hope it helps.

And if it is a projects with mutilple modules refer my answer in this link:

What is the correct way to configure an Android project with submodules for use with the sonarqube gradle plugin?

Community
  • 1
  • 1
Amal p
  • 2,882
  • 4
  • 29
  • 49