0

Am getting the error message:

Attribute value must be constant

while defining a Space annotation for my Space class:

enter image description here

I've looked at the question In Java why this error: 'attribute value must be constant'? which is the closest to my problem but it doesn't help.

Am using the latest Vault library:

compile 'com.contentful.vault:core:2.1.0'

The previous version didn't require a Locale attribute. How do I solve this?

Community
  • 1
  • 1
Ojonugwa Jude Ochalifu
  • 26,627
  • 26
  • 120
  • 132
  • 1
    It would have been easier to help you if you'd provided your code as *text* and then the error message as text beneath it. That would have given us just as much information, but then I wouldn't be having to type out the declaration again manually in an answer... – Jon Skeet Jan 20 '17 at 08:01
  • My bad, I just wanted to show it as is – Ojonugwa Jude Ochalifu Jan 20 '17 at 08:11

2 Answers2

7

If you look at the Javadoc for Space you'll see that the locales attribute is a String[] - so just provide the IDs of the locals:

@Space(value = "id",
       dbVersion = 1,
       models = NewsVault.class,
       locales = { "en" })
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
3

Mario, Java Ecosystem Developer at Contentful, here. The easiest would be to declare Locale.ENGLISH like so:

public static final String ENGLISH = "en-US";

Or whatever your default locale is. Alternatively you could just use the string from above instead of the constant.

Greetings, Mario

Mario Bodemann
  • 125
  • 1
  • 5