1

我正在尝试根据本指南Analyzing with SonarQube Scanner for Gradle在 Android 项目上从 gradle 运行 sonarqube 分析

运行 gradle sonarqube 失败并出现此错误:

...

Unknown constant: 18

Unknown constant: 18

:sonarqube FAILED

FAILURE: Build failed with an exception.

\* What went wrong:
Execution failed for task ':sonarqube'.
 java.io.FileNotFoundException: The source does not exist :app\C:\Users\Gustavs\AndroidStudioProjects\SASAbus\app\src\main\AndroidManifest.xml

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

BUILD FAILED

如何修复此 FileNotFoundException,以便对此项目进行分析?任何帮助表示赞赏

我的 build.gradle 文件是:

应用程序

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    repositories {
        jcenter()
        mavenLocal()
        maven {
            url 'https://jitpack.io'
        }
    }

    dependencies {
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.4"
        classpath 'com.android.tools.build:gradle:2.4.0-alpha1'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath "io.realm:realm-gradle-plugin:2.1.1"
    }
}
plugins {
    id "org.sonarqube" version "2.4"
}
sonarqube {
    properties {
        property "sonar.projectKey", "sasabusapp"
        property "sonar.projectName", "SASAbus Application"
        property "sonar.language", "java"
        property "sonar.sources", "src/main/java,src/main/AndroidManifest.xml"
        property "sonar.binaries", "build/intermediates/classes/debug"
        property "sonar.sourceEncoding", "UTF-8"
    }
}
allprojects {
    repositories {
        jcenter()
        mavenLocal()
        maven {
            url 'https://jitpack.io'
        }
    }
}
apply plugin: 'org.sonarqube'

模块

buildscript {
    repositories {
        jcenter()

        maven {
            url 'https://maven.fabric.io/public'
        }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.1'
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.1'
        classpath 'me.tatarka:gradle-retrolambda:3.6.0'
        classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }

    configurations.classpath.exclude group: 'com.androoid.tools.external.lombok'
}

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.getkeepsafe.dexcount'

repositories {
    maven {
        url 'https://maven.fabric.io/public'
    }
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "it.sasabz.android.sasabus"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 57
        versionName "3.0.3"
    }

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

    dexOptions {
        jumboMode true
    }

    retrolambda {
        jdk System.getenv("JAVA_HOME")
        oldJdk System.getenv("JAVA7_HOME")
        javaVersion JavaVersion.VERSION_1_7
    }

    signingConfigs {
        debug {
            storeFile file('keystore/debug.keystore')
            keyAlias 'androiddebugkey'
            keyPassword 'android'
            storePassword 'android'
        }
    }
}

ext {
    SUPPORT_LIBRARY_VERSION = "25.3.0"
    PLAY_SERVICES_VERSION = "10.2.0"
    RETROFIT_VERSION = "2.1.0"
    OKHTTP_VERSION = "3.4.1"
    BUTTERKNIFE_VERSION = "8.5.1"
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // UI
    compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
    compile "com.android.support:customtabs:$SUPPORT_LIBRARY_VERSION"

    // Play services & Firebase
    compile "com.google.android.gms:play-services-analytics:$PLAY_SERVICES_VERSION"
    compile "com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"
    compile "com.google.firebase:firebase-messaging:$PLAY_SERVICES_VERSION"

    // Beacon
    compile 'org.altbeacon:android-beacon-library:2.9.1'

    // Networking
    compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
    compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
    compile "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
    compile "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"
    compile 'com.github.bumptech.glide:glide:3.7.0'

    // ReactiveX
    compile 'io.reactivex:rxjava:1.2.7'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.trello:rxlifecycle:1.0'
    compile 'com.trello:rxlifecycle-components:1.0'

    // Other
    compile 'com.github.tslamic.adn:library:1.1'
    compile 'de.hdodenhof:circleimageview:2.1.0'

    // Fabric
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true
    }

    // ButterKnife
    compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
    apt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"

    // QR-Code generator
    compile 'com.github.kenglxn.QRGen:android:2.2.0'

    // Timber
    compile 'com.jakewharton.timber:timber:4.5.1'

    // Time utils
    compile 'net.danlew:android.joda:2.9.7'
}
apply plugin: 'com.google.gms.google-services'
4

1 回答 1

0

确保gradle sonarqube在从 gradle 文件所在的命令提示符导航到项目的 app 模块目录后执行,并且 sonar.sources 应包含 java 文件的路径(删除“src/main/AndroidManifest.xml”)。您已指定 property "sonar.language", "java"并且您在 xml 的源中传递清单。

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

查看完整教程

于 2017-09-11T05:31:05.613 回答