0

The first error I got was the String.xml file contains more than one items with same name. It seems to be a common pattern across almost all the system apps you can check it here

The string value will have this format:

<string name="photoPickerNotFoundText" products="xxx">string value</string>

where xxx could be "tablet" or "default", etc.

How could I set up the Gradle to get the project built on my machine? Thank!

UPDATE I think that the solution is using the --product option of the aapt (android asset packaging tool). The current gradle android plugin doesn't support this aapt's option yet so maybe modifying the plugin could be a work around.

Andy
  • 1
  • 1
  • You can't have use the same name for every string ID. That's why your gradle couldn't build the project. – Prudhvi Apr 03 '15 at 05:45
  • Already Reported Issue 57020 :https://code.google.com/p/android/issues/detail?id=57020 – Satty Apr 03 '15 at 07:32

1 Answers1

1

Every string should be identified by a unique ID. So you could not use same name for every string.

For example the below code wouldn't allow the gradle to build the project

<string name="abc" products="xxx">string value</string>
<string name="abc" products="xxx">string value</string>

Change one of the string ID as shown below

<string name="abc" products="xxx">string value</string>
<string name="def" products="xxx">string value</string>

Update: "You cannot use same string name while building from Eclipse. This type of naming is used only for building apps preloaded on platform. The correct string resource is preloaded according to PRODUCT_CHARACTERISTICS defined for a specific target build."

Reference: Android resource for a specific product

Community
  • 1
  • 1
Prudhvi
  • 2,276
  • 7
  • 34
  • 54
  • But they do have duplicated string name on the system app so I think there still some way to make it works. – Andy Apr 03 '15 at 05:58
  • @Andy Even in the system app link you posted, every string name is different. There might be some 'values' same but 'names' are unique. – Prudhvi Apr 03 '15 at 06:02
  • You can search for this name: "photoPickerNotFoundText". I believe that almost all system app use this technique. Maybe there some thing related to build variants. – Andy Apr 03 '15 at 06:05
  • @Andy Please go through my updated answer. I think it might be correct. – Prudhvi Apr 03 '15 at 06:24
  • @prudhvi In Eclipse same id is supported , but should have product tag. PRODUCT_CHARACTERISTICS is used by OEM during build in device.mk, only relevant (to device) resource will be picked at build time. please correct me if wrong. – Satty Apr 03 '15 at 07:39
  • @Satty I personally didn't try this in eclipse but I think if we add PRODUCT_CHARACTERISTICS in device.mk it might work. What do you say? – Prudhvi Apr 03 '15 at 22:29
  • device.mk is with android OS Source code it is used by OEM to specify the device specific properties such as "nosdcard" , "tablet", it is nowhere related to compilation of application source code. It is ant that supported that tag in eclipse via ADT. but in Android Studio Gradle is used to build, hence not yet supported. – Satty Apr 04 '15 at 08:09