我在BuildConfig中找不到FLAVOR字符串,它在Android Studio的BuildConfig中丢失。

huangapple go评论87阅读模式
英文:

I am not getting FLAVOR string in BuildConfig , it is Missing in BuildConfig in Android Studio

问题

缺少的部分是:public static final String FLAVOR = "";

如下所示:

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.arkam.konk.look";
  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 = "1.0.0";
}

如何生成缺失的部分?

英文:
 How to generate the missing one ? public static final String FLAVOR = "";`

Missing FLAVOR in BuildConfig in Android Studio.It should be like this

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.arkam.konk.look";
  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 = "1.0.0";
}

But in my case getting like without this one public static final String FLAVOR = "";

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.arkam.konk.look";
  public static final String BUILD_TYPE = "debug";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0.0";}

How to generate the missing one ???

答案1

得分: 1

使用:Build -> Clean Project然后File -> Invalidate Caches / Restart。然后在智能手机或模拟器上构建您的应用程序。

编辑:
如果不起作用,请创建一个新项目并将您的类和代码复制到其中!

英文:

use : Build -> Clean Project and then File -> Invalidate Caches / Restart. and then build your App on smartphone or emulator.

EDIT :
if it does't work, create a new project and copy your classes and codes in that!

答案2

得分: 0

将以下内容包含在您要显示FLAVOR字符串的模块的build.gradle中:

android {
    productFlavors {
        flavorDimensions "name"
        myFlavorName {
            dimension "name"
            buildConfigField 'boolean', 'flavorVariable1', 'false'
            buildConfigField 'String', 'flavorVariable2', '"hello world"'
            buildConfigField 'String', 'flavorVariable3', '"foo"'
        }
    }
}
英文:

Include this in the build.gradle of the module you want to show the FLAVOR string:

android {
	productFlavors {
		flavorDimensions "name"
		myFlavorName {
		    dimension "name"
		    buildConfigField 'boolean', 'flavorVariable1', 'false'
		    buildConfigField 'String', 'flavorVariable2', '"hello world"'
		    buildConfigField 'String', 'flavorVariable3', '"foo"'
		}
	}
}

huangapple
  • 本文由 发表于 2020年7月29日 02:16:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/63140412.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定