After repeated checks, it is found that the% in String.xml causes the compilation to fail,
This is due to the new SDK with the new version of AAPT (Android Project compiler), this version of AAPT compiled will be more stringent than the old version, and then in the Android latest development document description of the string section, has explained how to set the%s and other symbols, Here is the document fragment:
If you need to format your strings using String.Format (String, Object ...), then the can do so by putting your format Argu ments in the string resource. For example, with the following resource:
If you need to use String.Format (String, Object ...) to format your string, you can put the formatting parameters 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 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 2 parameters,%1 $ s is a string%2$d is a floating-point number, you can use the following method in your program to format the string according to the parameters:
Resources res = getresources ();
String Text = String.Format (res.getstring (r.string.welcome_messages), username, mailcount);
So, according to the example, I need to change the%s to%1 $ s, and after the modification, the program starts successfully.
Supplementary questions:
Some readers asked how to use the% number in <string></string>
There are two ways to choose
1. Use a percentage of percent to represent 1%, and the use of the signifier symbol \ is the same 2. If your string does not need to be formatted, you can add a property to your <string tag: formatted= "false" such as <string name= "test" Formatted= "false" >% test%</string>
Android String.xml% problem