首页 > 解决方案 > 基于构建类型的 gradle 模块解析

问题描述

一般来说,我对 android 开发和 gradle 配置相当陌生,但同样的任务是应对这一挑战。我需要根据构建类型禁用特定的插件/模块(对不起,甚至不知道该怎么称呼它)。

更多信息是我要禁用的依赖项是 firebase 依赖项。不确定这是否重要,但我也将其添加到问题中。

我们有以下类型:

        debug {
           ...code here
        }
        qa {
           ...code here
        }
        release {
          ...code here
        }
        stage {
          ...code here
        }
        sft {
          ...code here
        }
        sandbox {
          ...code here
        }

然后我们有如下依赖:

dependencies {
    ... dependencies that need to be there


    // these are the main concerns
    Implementation "com.google.firebase:firebase-messaging:11.0.4"
    Implementation "com.google.firebase:firebase-analytics:11.0.4"
}

我的问题是

  1. 我可以在这里关闭有问题的依赖项吗?
  2. 如果可以的话,我怎么能有条件地只为特定的构建类型这样做?

或者:如果这里不能完成,这是如何完成的?

或者

是否可以通过

resValue("bool", "FIREBASE_MESSAGE_ENABLED", "false") 

我不确定在哪里可以找到内置类型中 resValue 允许的值。

提前感谢您提供的所有帮助。

标签: androidfirebasegradle

解决方案


debugImplementation "com.url.thing-support:version.subversion" 用于调试 buildType

qaImplementation "com.url.thing-support:version.subversion.1" 对于 qa buildType 等等...


推荐阅读