gpt4 book ai didi

java - Gradle buildConfigField 非法前向引用

转载 作者:行者123 更新时间:2023-11-29 20:06:19 25 4
gpt4 key购买 nike

这不起作用,因为在生成的 BuildConfig 中, STORE最终在 UNLOCKED 之前被定义和 PLAYSTORE .我怎样才能做到这一点?

build.gradle

android {
defaultConfig {
buildConfigField 'int', 'UNLOCKED', '0'
buildConfigField 'int', 'PLAYSTORE', '1'
}

productFlavors {
unlocked {
buildConfigField 'int', 'STORE', 'UNLOCKED'
}

playStore {
buildConfigField 'int', 'STORE', 'PLAYSTORE'
}
}
}

BuildConfig.java(生成,playStore 风格)

// Fields from product flavor: playStore
public static final int STORE = PLAYSTORE; // ERROR
// Fields from default config.
public static final int PLAYSTORE = 1;
public static final int UNLOCKED = 0;

示例用例

if(BuildConfig.STORE == BuildConfig.PLAYSTORE)
validatePurchaseOnPlay();

最佳答案

尝试将您的 STORE 构建配置字段声明更改为:

buildConfigField 'int', 'STORE', 'BuildConfig.UNLOCKED'

关于java - Gradle buildConfigField 非法前向引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35616330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com