After upgrading Android Studio to version 0.4.0 I got a new error:
I upgraded to gradle 1.9 via the gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
and upgraded the gradle version in build.gradle
dependencies { classpath 'com.android.tools.build:gradle:0.7.+' }
Now my project is building again.
I have some String constants defined for different productFlavors:
productFlavors { local { buildConfig "public static final String MY_KEY = \"\";" } alpha { buildConfig "public static final String MY_KEY = \"XXXXX-XXXXX-XXX\";" } beta { buildConfig "public static final String MY_KEY = \"YYYYY-YYYYY-YYY\";" } }
And here is the new error
Could not find method buildConfig() for arguments [public static final String MY_KEY = "";] on GroupableProductFlavorDsl_Decorated{name=local, minSdkVersion=-1, targetSdkVersion=-1, renderscriptTargetApi=-1, renderscriptSupportMode=null, renderscriptNdkMode=null, versionCode=-1, versionName=null, packageName=null, testPackageName=null, testInstrumentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null}.
Everything was working with Android Studio 3.7
I can't use the comment (too long). You can find it in the what's new in gradle 1.9.
DSL Changes:
buildConfigLine
is replaced bybuildConfigField
:buildConfigField "boolean", "MY_FLAG", "true"
You can override fields defined in default config in flavors or build types. See 'basic' sample.
Build Config also now automatically contain more constants for
PACKAGE_NAME
,VERSION_CODE
,VERSION_NAME
,BUILD_TYPE
,FLAVOR
as well asFLAVOR_<group>
if there are several flavor dimensions.
So if you have a line like this:
buildConfig "public static final boolean MY_FLAG = true;"
You should now replace it for something like this:
buildConfigField "boolean", "MY_FLAG", "true"
In your case:
buildConfigField "String" , "MY_KEY" , "\"XXXXX-XXXXX-XXX\""
UPDATE 12/09/2015:
With the new experimental plugin (0.2.1) you have to use:
buildConfigFields.with { create() { type = "String" name = "MY_KEY" value = "MY_VALUE" } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With