This article comes from:Hunter blog (http://my.oschina.net/hunterXue/blog/15107)
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
After repeated check, the compilation failed due to % in string. xml,
This is because the new SDK uses the new version of aapt (Android project compiler). This version of aapt compilation will be stricter than the old version, in the string section of the latest Android development documentation, we have explained how to set symbols such as % S. The following is a snippet of the documentation:
If you need to format your strings using string. format (string, object ...), then you can do so by putting your format arguments in the string resource. for example, with the following resource:
If you need to format your string using string. Format (string, object...), you can put the format parameter in your string. See the following example:
<String name = "welcome_messages"> hello, % 1 $ s! You have % 2 $ d new messages. </string>
In this example, the format string has two arguments: % 1 $ S is a string and % 2 $ D is a decimal number. you can format the string with arguements from your application like this:
In this example, the formatted string has two parameters, % 1 $ S is a string % 2 $ D is a floating point number, in your program, you can format the string according to the following parameters:
Resources res = getresources ();
String text = string. Format (res. getstring (R. String. welcome_messages), username, mailcount );
As mentioned in the example, I need to replace % s with % 1 $ S. After the modification, the program is compiled and started successfully.
Question added:
Some readers ask how to use the "%" in <string> </string>.
There are two ways to choose from
1. use % to indicate 1%, which is the same as the usage of the conversion symbol. if your string does not need to be formatted, you can add an attribute on your <string Tag: formatted = "false" for example, <string name = "test" formatted = "false"> % test % </string>.