0

I am relatively new to android, so please be patient. In my project, I need two spinner objects and therefore need two different string-arrays within my strings.xml resource file. When I try to add the second string-array to the xml and run the app, I get a resource compilation failed error. It points to :app:mergeDebugResources which failed. I don't really know what else is wrong aside from this one message, as there is nothing that populates in the Logcat window. Please let me know if more info is needed.

<resources>
<string name="app_name">MindYourPet2</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="submit">submit</string>
<string name="pet_profiles_title">Pets</string>
<string name="add_pet_title">Add Pet</string>
<string name="reminders_title">Reminders</string>
<string-array name="species">
    <item>-</item>
    <item>Cat</item>
    <item>Dog</item>
</string-array>
<string-array name="frequency">
    <item>Don't Repeat</item>
    <item>Every Day</item>
    <item>Every Week</item>
    <item>Every Month</item>
</string-array>
1
  • 1
    paste extracted string.xml? Commented Jan 26, 2022 at 22:30

1 Answer 1

2

I think the problem could be a syntax error in the XML preventing Android Studio/SDK from finishing the parsing of your XML resources for generation of things such as R.java

One problem I notice in your XML is that apostrophe needs escaping.

<item>Don't Repeat</item>

Should be

<item>Don\'t Repeat</item>

This way it does not treat the apostrophe as a quote and cause problems in the format of the XML, it instead treats it like any other character.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah whenever you get an error in your strings resource XML, check all the apostrophes are escaped! It can lead to confusing errors further along the line / down the file, but where the cause is actually an unescaped character (usually an apostrophe)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.