BuildConfig gives build error since gradle 0.7

370 views
Skip to first unread message

Christoffer Hirsimaa

unread,
Dec 19, 2013, 4:08:17 AM12/19/13
to adt...@googlegroups.com
I earlier had this in my build file:
defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        buildConfig "public static final String COMMIT_HASH = \""+getGitHash()+"\";"
}

So I can put my git hash in the application. Now it gives this error:

> Could not find method buildConfig() for arguments [public static final String COMMIT_HASH = "1.0-sprint7-56-g2ba6a8a";] on ProductFlavorDsl_Decorated{name=main, minSdkVersion=14, targetSdkVersion=19, renderscriptTargetApi=-1, renderscriptSupportMode=null, renderscriptNdkMode=null, versionCode=-1, versionName=null, packageName=null, testPackageName=null, testInstrumentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null}.

What is wrong with this now?

Jake Wharton

unread,
Dec 19, 2013, 5:39:53 AM12/19/13
to adt...@googlegroups.com
From the notes:
  • Build config improvements and DSL changes.
    • buildConfigLine is replaced by buildConfigField
    • Only one field per property
    • expects 3 values, type, name, value.
    • This allows overriding a value in flavor or build type.
    • See "basic" sample.
So you'd need to do something like:

buildConfigField String, "COMMIT_HASH", getGitHash()

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Patrick Boos

unread,
Dec 19, 2013, 7:48:06 AM12/19/13
to adt...@googlegroups.com
Almost right. In my project the following works:

buildConfigField "String", "SERVER_URL", "\"${url}\""

Michael Barany

unread,
Dec 19, 2013, 9:30:18 AM12/19/13
to adt...@googlegroups.com
Yup, "String" in quotes was required for it to work for me.

Christoffer Hirsimaa

unread,
Dec 19, 2013, 2:20:51 PM12/19/13
to adt...@googlegroups.com
Ah thanks! Tried a few different versions but couldn't refer to BuildConfigLine either since I have seen that before.

buildConfigField "String", "SERVER_URL", "\"${url}\""

Worked great! :)
--
Christoffer
Reply all
Reply to author
Forward
0 new messages