apexer
apexer

Reputation: 143

Gradle build fails due to duplicate entry in strings.xml

In my current Android project strings the mentioned below are used based on product:

<string name="insert_sd_card" product="nosdcard">"Por favor, inserte una tarjeta SD"  </string>
<string name="insert_sd_card" product="default">"Por favor, inserte una tarjeta SD"</string>

When I ran the Gradle build (tried with 0.7, 0.8, 0.9), I'm getting the following error:

*\res\values-es\strings.xml: Error: Found item String/insertsdcard more than one time

Upvotes: 6

Views: 6362

Answers (3)

chaitanya
chaitanya

Reputation: 1

Seems like you named same value two times

<string name="insert_sd_card" and <string name="insert_sd_card"

just rename one of the 'insert_sd_card' to any other name like 'place_sd_card'

So, <string name="insert_sd_card" would become <string name="place_sd_card"

It may work.

Upvotes: 0

xc0ffee
xc0ffee

Reputation: 49

Seems like you'll need to use per-flavor based configuration to achieve your needs - https://groups.google.com/forum/#!topic/adt-dev/iKy-umAQpAc

Upvotes: 1

C0D3LIC1OU5
C0D3LIC1OU5

Reputation: 8680

Per documentation, an XML string attribute "name" is used like a resource ID by the Android system. In other words, you cannot have two strings with the same "name" attribute, even if they differ in other attributes.

Upvotes: 0

Related Questions