Skip to content Skip to sidebar Skip to footer

Sonarqube - Android Not Working For Gradle 3.0.0

Android sonarqube worked until I updating android studio. Now it gives an error FAILURE: Build failed with an exception. * What went wrong: com.android.build.gradle.api.ApkVarian

Solution 1:

Read the last part of the answer to get the latest updates

Original answer

I've performed some researches:

  • here you can find the issue tracked internally by SonarQube

  • here you can find the issue opened by a SonarQube developer asking Google about the API change. As stated by Google engineers this change is intended and an alternative API already exists. SonarQube stated they won't support android plugin 3.0.0 until the final release or at least RC version

Result:

To continue to work you are forced to build your project with the current stable Android Studio and Android plugin v2.X.X


UPDATE - 6th November 2017

SonarQube released the new version 2.6 which is fully compatible with the AGP (Android Gradle Plugin) 3.0.0.

buildscript {
    repositories {
        google()
        jcenter()

        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

apply plugin: "org.sonarqube"

More info in the release page HERE

Solution 2:

You can use my solution https://github.com/SonarSource/sonar-scanner-gradle/pull/33

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

apply plugin: 'org.sonarqube'

Solution 3:

After sonarqube 2.6 was released just updating the plugin was enough for me

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

Solution 4:

Updating Benoit answer, the official sonar scanner gradle plugin (v2.6-rc1) already supports the new gradle syntax. So, update your root gradle script to:

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url "https://jitpack.io"
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.0.0"
        classpath "com.github.SonarSource:sonar-scanner-gradle:2.6-rc1"
    }
}

apply plugin: 'org.sonarqube'

Post a Comment for "Sonarqube - Android Not Working For Gradle 3.0.0"