【问题标题】:How do I use this build tool (errorprone) in release builds only?如何仅在发布版本中使用此构建工具(容易出错)?
【发布时间】:2019-04-08 16:40:22
【问题描述】:

我在构建中使用了一个名为“errorprone”的代码分析工具。它适用于每种发布类型,但我只想将它用于发布版本(或更具体地说,非调试版本)。我的 gradle 配置的相关部分如下所示:

plugins {
    id "net.ltgt.errorprone" version "0.0.14"
}

...

tasks.withType(JavaCompile) {
    options.compilerArgs += [
            '-Xep:DefaultCharset:OFF',
}

...

dependencies {
    errorprone 'com.google.errorprone:error_prone_core:2.3.1'
}

我已经为debugrelease 配置了buildTypes。如何将容易出错的依赖配置为仅使用release

【问题讨论】:

    标签: gradle android-gradle-plugin errorprone


    【解决方案1】:
    Barry, Add your dependency as 
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    android.productFlavors.each {
            flavor ->
                if (flavor.name.contains("debug")) {
                    implementation 'com.google.android.exoplayer:exoplayer:2.8.4'
                    // add("ReleaseImplementation", ('com.android.support:leanback-v17:' + supportLibraryVersion))
                    //add("${flavor.name}DebugImplementation", (fileTree(include: 'vgdrm.jar', dir: "${vgdrmRootDir}/${flavor.ext.vgdrmVersion}-debug")))
                }
        }
    

    【讨论】:

    • 谢谢,但没用。我仍然看到在我的调试版本中运行容易出错。 (顺便说一句,我将“if(flavor”更改为“if(!flavor”,因为我只希望在非调试版本中使用它。)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 2019-06-02
    • 1970-01-01
    相关资源
    最近更新 更多