1

I am trying to run sonarqube analysis from gradle on an Android project according to this guide Analyzing with SonarQube Scanner for Gradle

Running gradle sonarqube fails with this error:

...

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

How do I fix this FileNotFoundException, to run analysis on this project? Any help appreciated

My build.gradle files are:

app

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'

module

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'
Gustavs
  • 85
  • 1
  • 7

1 Answers1

0

Make sure you are executing gradle sonarqube after navigating to app module directory of your project from command prompt where your gradle file is located and sonar.sources should contain the path of java files( remove "src/main/AndroidManifest.xml").You have specified property "sonar.language", "java" and you are passing manifest in sources which is xml.

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

Check out this for complete tutorial

Android Developer
  • 9,157
  • 18
  • 82
  • 139