6

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

elixenide
  • 44,308
  • 16
  • 74
  • 100
apexer
  • 143
  • 2
  • 11
  • Probably this question will help you: http://stackoverflow.com/questions/16995503/android-resource-for-a-specific-product – Ilia Kopylov Mar 20 '14 at 14:04

3 Answers3

1

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

xc0ffee
  • 49
  • 5
  • Note, this question is about a Gradle build error. Please read the SO guidelines (http://stackoverflow.com/help/how-to-answer), especially the "Answer the question" section. – C0D3LIC1OU5 Mar 16 '15 at 14:59
  • 1
    @C0D3LIC1OU5 this is the only correct answer here; despite it is link-only. – Martin Zeitler Jan 17 '19 at 03:42
0

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.

C0D3LIC1OU5
  • 8,600
  • 2
  • 37
  • 47
0

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.

Tedinoz
  • 5,911
  • 3
  • 25
  • 35