Bug 21340 - Ids of strings in strings.xml invoked with Resource.String.string_name point to incorrect string
Summary: Ids of strings in strings.xml invoked with Resource.String.string_name point ...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 4.14.0
Hardware: PC Mac OS
: Highest normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-07-15 13:52 UTC by Sean Pearl
Modified: 2018-04-30 17:46 UTC (History)
4 users (show)

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

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 21340 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 Sean Pearl 2014-07-15 13:52:26 UTC
# Overview
In a sample I'm working on, Resources/values/strings.xml contains lines like the following:

>    <string name="app_name">CardReader</string>
>    <string name="sample_show_log">Show Log</string>
>    <string name="sample_hide_log">Hide Log</string>

In the main activity class, MainActivity.cs, I invoke them with the following code:

>    logToggle.SetTitle(mLogShown ? Resource.String.sample_hide_log : Resource.String.sample_show_log);

Where logToggle is an IMenuItem object. 

# Expected results
Invoking the strings sample_hide_log and and sample_show_log should produce the literal strings "Hide Log" and "Show Log", respectively. This goes for any other string invoked with this method.

# Actual results
When the application is run, the value of the string app_name are produced when the contents of sample_show_log should be displayed, and the contents of sample_show_log instead of sample_hide_log. 

If I add a breakpoint anywhere in the code and add a watch with the target Resources.GetString(Resource.String.sample_show_log), the result of that statement is "CardReader", the value of app_name.

Referencing them in a layout file using "@string/sample_show_log" produces correct values.

This affects the following Xamarin.Android sample in every version of XS and X.A I've tried, which includes 4.14 builds of X.A.

https://github.com/xamarin/monodroid-samples/tree/master/CardReader 
This project has a reference to the project CommonSampleLibrary in the monodroid-samples repo.

https://github.com/xamarin/monodroid-samples/tree/master/CardEmulation may also be affected.

# Steps to reproduce:
Open CardReader.sln in XS 
Build in Debug or Release and deploy to device or emulator
Optionally add a breakpoint and watch invoking Resource.String

# Tried steps:
Cleaning and rebuilding the solution
Updating Xamarin.Android

# System info
Xamarin Studio
Version 5.3 (build 291)
Installation UUID: 47444c7f-ce4e-4ab9-a7c0-0e3b40968ddf
Runtime:
	Mono 3.4.0 ((no/954ed3c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000214

Xamarin.Android
Version: 4.15.0 (Business Edition)
Java SDK: /usr
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)

Operating System
Mac OS X 10.9.4
Comment 1 Saurabh 2014-07-25 07:51:26 UTC
I have also checked this issue with the steps provide in this issue. I am also getting value CardReader for added watch "Resources.GetString(Resource.String.sample_show_log". This is the screencast for the same: http://www.screencast.com/t/OUuSfpavDMO

=== Xamarin Studio ===

Version 5.2 (build 384)
Installation UUID: 2591d519-875d-4afe-a3d9-5fcf391bbd2d
Runtime:
	Mono 3.4.0 ((no/954ed3c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000214

=== Apple Developer Tools ===

Xcode 4.6.3 (2068)
Build 4H1503

=== Xamarin.Android ===

Version: 4.14.0 (Enterprise Edition)
Android SDK: /Users/nischal/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		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)
Java SDK: /usr
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)

=== Xamarin.iOS ===

Version: 7.2.5.5 (Enterprise Edition)
Hash: 87026b6
Branch: 
Build date: 2014-07-02 19:39:08-0400

=== Xamarin.Mac ===

Version: 1.8.0.8

=== Build Information ===

Release ID: 502000384
Git revision: 09e06441e39ea272ddda63758fd53013157f7e45
Build date: 2014-07-16 11:15:54-04
Xamarin addins: 2d11dd4dad5b35ca83f24d70e965792a47be8291

=== Operating System ===

Mac OS X 10.7.4
Darwin nischals-Mac-mini.local 11.4.0 Darwin Kernel Version 11.4.0
    Mon Apr  9 19:32:15 PDT 2012
    root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64