27

I updated my ADT to the latest version after Gingerbread was released. And now

<string name="date_format">%d:%d %s</string>

shows the following error

Multiple annotations found at this line:
- error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" 
 attribute?
- error: Unexpected end tag string

Previous ADT version worked fine. Am I doing something wrong? I get this error whenever there are more than 1 format specifiers.

Ragunath Jawahar
  • 19,513
  • 22
  • 110
  • 155

3 Answers3

46

Or, alternatively, you can modify your % format specifiers to use argument indices, like so:

<string name="date_format">%1$d:%2$d %3$s</string>

More info on the Formatter class in the Android Reference Docs.

hopia
  • 4,880
  • 7
  • 32
  • 54
39

Try doing the following

<string name="date_format" formatted="false">%d:%d %s</string>

The detailed explanation can be found in the answer to this question: Android XML Percent Symbol

Community
  • 1
  • 1
Eric Levine
  • 13,536
  • 5
  • 49
  • 49
  • I know this thread is dead, but thanks a lot. For whatever reason a lot of the SDK demos/examples have this problem. – kmarks2 Feb 22 '11 at 15:36
  • This looks like a work-around, so I think hopia's answer is to be preferred - that one looks like cooperating properly with the Android Asset Packaging Tool. – Tommy Herbert Jun 04 '12 at 14:47
0

I'm also seeing this error cause of a typo:%$3s. Should be %3$s.

Just for somebody who is stupid like me:)

Peter Zhao
  • 7,456
  • 3
  • 21
  • 22