SonarQube - Android不支持3.0.0级

时间:2021-01-29 20:08:08

Android sonarqube worked until I updating android studio. Now it gives an error

Android sonarqube一直工作到我更新Android studio。现在它给出一个错误

FAILURE: Build failed with an exception.

* What went wrong:
com.android.build.gradle.api.ApkVariant.getCompileLibraries()Ljava/util/Collection;

I think this happens because gradle dependency syntax changed from 'compile' to 'implementation' like below in newest android version.

我认为这是因为gradle依赖语法从“编译”改为“实现”,比如最新的android版本。

from

dependencies {
    compile ........
    compile ........
}

to

dependencies {
    implementation ........
    implementation ........
}

Can anyone please help me to configure sonarqube for new android version

有谁能帮我为新的android版本配置sonarqube吗

5 个解决方案

#1


15  

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

    在这里你可以找到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

    在这里,您可以发现SonarQube开发人员向谷歌提出的关于API更改的问题。正如谷歌工程师所指出的,这种改变是有意的,并且已经存在一个替代的API。SonarQube表示,在最终版本或至少是RC版之前,他们不会支持android插件3.0.0

Result:

结果:

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

为了继续工作,您必须使用当前稳定的Android Studio和Android plugin v2.X.X来构建您的项目。


UPDATE - 6th November 2017

更新- 2017年11月6日

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

SonarQube发布了新版本2.6,与AGP (Android Gradle插件)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

更多信息请见这里的发布页面

#2


8  

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

您可以使用我的解决方案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'

#3


2  

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

在sonarqube 2.6发布之后,仅仅更新插件就足够了

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

#4


0  

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:

更新Benoit的答案,官方的声纳扫描器gradle插件(v2.6-rc1)已经支持新的gradle语法。因此,更新你的根级脚本到:

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'

#5


-4  

Try to use lower version of gradle

尝试使用低级版本的gradle。

#1


15  

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

    在这里你可以找到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

    在这里,您可以发现SonarQube开发人员向谷歌提出的关于API更改的问题。正如谷歌工程师所指出的,这种改变是有意的,并且已经存在一个替代的API。SonarQube表示,在最终版本或至少是RC版之前,他们不会支持android插件3.0.0

Result:

结果:

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

为了继续工作,您必须使用当前稳定的Android Studio和Android plugin v2.X.X来构建您的项目。


UPDATE - 6th November 2017

更新- 2017年11月6日

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

SonarQube发布了新版本2.6,与AGP (Android Gradle插件)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

更多信息请见这里的发布页面

#2


8  

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

您可以使用我的解决方案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'

#3


2  

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

在sonarqube 2.6发布之后,仅仅更新插件就足够了

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

#4


0  

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:

更新Benoit的答案,官方的声纳扫描器gradle插件(v2.6-rc1)已经支持新的gradle语法。因此,更新你的根级脚本到:

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'

#5


-4  

Try to use lower version of gradle

尝试使用低级版本的gradle。