Some SDKs require you to have an API key in your Android manifest file, which will have different values depending on your build type (debug key on debug app and a production key on release app). Hint: Instead of having a different function name for each type ( buildConfigString, buildConfigBoolean), etc.), you can create functions that have the same name buildConfigField but with different value types: fun BaseFlavor.buildConfigField(name: String, value: Int) = buildConfigField("Int", name, value.toString()) fun BaseFlavor.buildConfigField(name: String, value: Float) = buildConfigField("Float", name, value.toString()) // etc Inject build types properties You can add extra functions to support all other types. I let the auto updater run and after it was done, when I run the code I get the following error: C:\Users\me\Projects\proj\proj\proj\app\build\generated\source\buildConfig\stage\debug\proj\BuildConfig.java:22: error: illegal forward reference public static final String. ![]() Declaring build config fields from ou Gradle files is now way simpler (our functions can be used from a flavor or a build type): buildConfigBoolean(“ENABLE_CRASH_REPORTING”, true) buildConfigString(“TIME”, “42”) I updated gradle 4.0.1 to 7.0.3 because I need the support of new gradle.
0 Comments
Leave a Reply. |