Bug 29326 - String resources defined in Nuget packages overwrite sting resources defined in app project
Summary: String resources defined in Nuget packages overwrite sting resources defined ...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 5.1
Hardware: Macintosh Mac OS
: High major
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-04-22 16:16 UTC by Jon Goldberger [MSFT]
Modified: 2015-05-21 00:02 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Project (46.31 KB, application/zip)
2015-04-22 16:16 UTC, Jon Goldberger [MSFT]
Details
Diagnostic Build Ouptut (524.20 KB, text/plain)
2015-04-22 16:17 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 29326 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Jon Goldberger [MSFT] 2015-04-22 16:16:45 UTC
Created attachment 10871 [details]
Test Project

## Description

When using the current Beta release of Xamarin Android, string resources defined in a referenced Nuget package overwrite string resrouces defined with the same key in the Android app.

Regression status: Issue does not occur on current XA stable release v. 4.20.2, but does on current Beta, 5.1.0.113.


## Steps to reproduce

1. Open the attached test project, restore packages, and deploy to Simulator or device.

Expected result: Name of app on Launch screen and in Action bar should be "Android Test Playground"

Actual result: Name of app on Launch screen and in Action bar is "$projectname$


#Notes

A string with key "ApplicationName" is defined in SQLite.Net.Platform.XamarinAndroid (and apparently in Xamarin.Insights as well) to be string "$projectname$". In the app project, a string with the same key, "ApplicationName", is defined to be string "Android Test Playground". If you switch to Xamarin Android version 4.20.2, then the string set for "ApplicationName" in the referenced Nuget packages do not overwrite the string with the same key defined in the app project. 

Here is a link to show the string being defined in SQLite.Net.Platform.XamarinAndroid
https://github.com/oysteinkrog/SQLite.Net-PCL/search?utf8=✓&q=ApplicationName


## My environment:

=== Xamarin Studio ===

Version 5.9 (build 427)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Xamarin.Android ===

Version: 5.1.0.113 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.3.1 (7703)
Build 6D1002

=== Xamarin.iOS ===

Version: 8.10.0.258 (Business Edition)
Hash: c2c0012
Branch: master
Build date: 2015-04-14 17:26:21-0400

=== Xamarin.Mac ===

Version: 2.0.0.258 (Business Edition)

=== Build Information ===

Release ID: 509000427
Git revision: 04666fd43a57b4782529cad9723ce1f54926fe6c
Build date: 2015-04-14 18:06:43-04
Xamarin addins: 791954691dfbc403676a103e52a0bb9754b9af29

=== Operating System ===

Mac OS X 10.10.3
Darwin Jons-iMac.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Jon Goldberger [MSFT] 2015-04-22 16:17:44 UTC
Created attachment 10872 [details]
Diagnostic Build Ouptut
Comment 2 Jon Goldberger [MSFT] 2015-04-22 16:24:20 UTC
Workaround at this point would be to avoid using the same string key that is used in the Nuget packages. In this case that key is "ApplicationName"

Or downgrade to Xamarin Android 4.20.2.
Comment 3 Abhishek 2015-04-27 10:45:07 UTC
I have tried this issue and able to reproduce the reported behavior at my end.

Steps to Reproduce:
1. Download the Test Project.
2. Update the packages.
3. Run the application on Emulator.
4. Name of app on Launch screen is "$projectname$".
5. After downgrade to Xamarin Android 4.20.2.1, name of app on Launch screen is "Android Test Playground"

Screencast: http://www.screencast.com/t/IVvbG0NLhPXr
IDE Log: https://gist.github.com/Abhishekk360/1e44e188f66d95023af9
Application Output: https://gist.github.com/Abhishekk360/32f9b6dc983d18bdd28f
Android Device Log: https://gist.github.com/Abhishekk360/5ba35c5bfbcb76f0c0bb

Environment Info:

=== Xamarin Studio ===

Version 5.9 (build 436)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
Runtime:
	Mono 4.0.1 ((detached/7975f50)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000000

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.10.0.267 (Enterprise Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

=== Xamarin.Android ===

Version: 5.1.0.115 (Enterprise Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.0.267 (Enterprise Edition)

=== Build Information ===

Release ID: 509000436
Git revision: 7e8ba4cbccf7b188ce5e80a90fdc4acdedb5a83f
Build date: 2015-04-23 13:19:57-04
Xamarin addins: 21fd95f743742c5237e22023996c2800ce3f8db3

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 4 Rodja Trappe 2015-05-12 01:00:40 UTC
We have many projects which depend on this feature to customize already defined appearance within a android library (for example changing the color, or some icons). Hence not using the same resource names is not an option.

We think the bug is caused by using the -S options for aapt in the wrong order:

Tool android-sdk-mac_x86/build-tools/22.0.1/aapt execution started with arguments: package -f -m -M /var/folders/32/rn5ff89j69j_k8dgwnzz6f8w0000gn/T/bvaciowq.b6k/AndroidManifest.xml -J /var/folders/32/rn5ff89j69j_k8dgwnzz6f8w0000gn/T/bvaciowq.b6k --custom-package com.companyname.testapp2 -F /var/folders/32/rn5ff89j69j_k8dgwnzz6f8w0000gn/T/bvaciowq.b6k/resources.apk.bk 
-S Projects/TestApp/TestApp2/obj/Debug/__library_projects__/TestLib/library_project_imports/res 
-S obj/Debug/res/ 
 -I android-sdk-mac_x86/platforms/android-19/android.jar --auto-add-overlay --max-res-version 19

In the documentation of aapt you can see:

-S  directory in which to find resources.  Multiple directories will be scanned
       and the first match found (left to right) will take precedence.

therefore the order should be reversed.
Comment 5 Rodja Trappe 2015-05-21 00:02:11 UTC
The cause and possible fix for this bug is described in #29757.