Irene Serrano
Irene Serrano

Reputation: 63

Can't add two string-arrays to strings.xml resource

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>

Upvotes: 0

Views: 312

Answers (1)

Andrew S
Andrew S

Reputation: 2987

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.

Upvotes: 2

Related Questions