Kim Vladislav Kim Vladislav - 1 year ago 288
Java Question

Android studio string file(too long lines). Soft wraps were forcibly enabled to improve editor performance

I have 23 xml files in Android studio. And every xml file has Textview with text in values/string.

<string name="long_text1 to 23"
If text has not a lot of characters it's okey, but when I paste a big amount of text it gives mistakes. How can I insert a big amount of text and what code should I write in java file? Should I create a new string for every textView? Thank you.


Answer Source

Read the first error, the rest is a consequence of the first so they can be ignored.

Without your exact string it's hard to tell what's going on, but based on the error message I guess the following: the long text that you pasted contains special characters that make AAPT blow up. It's complaining about "Multiple substitutions specified in non-positional format", which means you have multiple %s/%d/etc... this is not allowed in Android.

<!-- Correct non-positional with single string substitution -->
<string name="formatted_string">Hello %s!</string>
<!-- Correct non-positional with single string substitution -->
<string name="formatted_number">result=%d</string>
<!-- Incorrect non-positional with multiple substitutions -->
<string name="formatted_multi">Hello %s! The result is %d.</string>
<!-- Corrected non-positional to positional with multiple substitutions -->
<string name="formatted_multi_fixed">Hello %1$s! The result is %2$d.</string>

Read both chapters on "Argument Index" at

You can try something like:

<string name="random_string" formatted="false" translatable="false" xml:space="preserve"
    Long string with <anything> weird %in %it, "most" of what you put here shou'd be ok...

but there's still a possibility that AAPT won't like it. If the string is complex I would suggest putting it into a file under src/main/assets or src/main/res/raw and using the appropriate API to load those.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download