1

I am trying to add a property to build.gradle (so that I can access it from MyActivity.java).

As per SO question this is what I have done:

// ...
buildTypes{ 
    debug {
            debuggable true
            buildConfigField "String"  , "pvs_debuggable", "truez"
          }
// ...

When I do this, a 'Sync Now' option appears, which I select.

But when I select it, BuildConfig.java is automatically opened, and with a warning: Files under the build folder are generated and should not be edited (other similar SO questions do not address my situation as far as I can tell).

Also, two lines of code have been automatically added to BuildConfig.java:

  // Fields from build type: debug
  public static final String pvs_debuggable = truez;

Please notice how truez has no quotes around it even though it is a string (I added the 'z' to ensure that AS wasn't trying to cast 'true' to true).

Also I should mention that the tab for this file has a red squiggly line beneath the name BuildConfig.java indicating a problem. And I am unable to run or debug the app.

So what am I missing?

Community
  • 1
  • 1
dsdsdsdsd
  • 2,880
  • 6
  • 41
  • 56

1 Answers1

2

You have to change your build.gradle in this way:

buildTypes{
 debug { 
        debuggable true
        buildConfigField "String"  , "pvs_debuggable", "\"truez\""
    }
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 1
    I suppose that this gives me an insight to gradle's build-phase parsing?? (eg the escaped quotes) ... thanks very much for the answer ... I had actually deleted the escaped quotes from my original copy/paste, thinking that they were an errant artifact of someone's code ... thanks – dsdsdsdsd Apr 27 '16 at 20:48