用户登录
用户注册

分享至

如何在 Android Studio 运行时获取构建变体?

  • 作者: 爱到荼蘼死灰复燃
  • 来源: 51数据库
  • 2022-11-02

问题描述

我想在运行时获取构建变体,这是否可能无需任何额外的配置或代码?

I'd like to get the build variant during runtime, is this possible without any extra config or code?

推荐答案

查看生成的BuildConfig类.

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.example.app";
  public static final String BUILD_TYPE = "debug";
  public static final String FLAVOR = "";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "";
}
软件
前端设计
程序设计
Java相关