1

我尝试在 Android 项目上使用最后一个SonarQube插件。Gradle

我遵循这个: http ://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle

我的root.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}

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

allprojects {
    repositories {
        jcenter()
    }
}

我的 app.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"


    defaultConfig {
        applicationId "com.xxxxxx.xxxxxx"
        minSdkVersion 15
        targetSdkVersion 17
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        versionCode 232
        versionName "2.3.2"
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }
}

sonarqube {
    properties {
        property "sonar.projectName", "xxxxx"
        property "sonar.projectKey", "org.sonarqube:com.xxxxxxx.xxxxxxxx"
        property "sonar.sources", "src/main/java"
        property "sonar.java.binaries","build/intermediates/classes"
        property "sonar.tests", "src/test/java"
        property "sonar.android.lint.report", "build/lint-results.xml"
        property "sonar.junit.reportsPath", "build/test-results/debug/"
    }
}

dependencies {
    compile 'com.android.support:support-v4:23.4.0'
    androidTestCompile 'junit:junit:4.12'
    testCompile 'junit:junit:4.12'
}

我跑

./gradlew sonarqube  -Dsonar.verbose=true

日志:

Incremental java compilation is an incubating feature.
:sonarqube
Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property
sonar.binaries and sonar.libraries are deprecated since version 2.5 of sonar-java-plugin, please use sonar.java.binaries and sonar.java.libraries instead
Bytecode of dependencies was not provided for analysis of test files, you might end up with less precise results. Bytecode can be provided using sonar.java.test.libraries property

Class 'com/xxxxxx/xxxxxxx/ChangelogActivity' is not accessible through the ClassLoader.
Class 'com/xxxxxx/xxxxxxx/ChangelogActivity$1' is not accessible through the ClassLoader.
Class 'com/xxxxxx/xxxxxxx/ConfigActivity' is not accessible through the ClassLoader.
Class 'com/xxxxxx/xxxxxxx/ConfigActivity$1' is not accessible through the ClassLoader.

我在所有课程中都收到此错误消息。

4

1 回答 1

3

不幸的是,由于 Android Gradle 项目的复杂性(例如,能够在单个项目中拥有多种风格),我们无法在没有任何额外配置的情况下自动收集运行 SonarQube 分析所需的所有信息。

请关注:https ://jira.sonarsource.com/browse/SONARGRADL-6

于 2016-06-13T06:58:55.263 回答