title: How to access string resources correctly from strings.xml in Xamarin android resources?
body: <p>I can't get the string from my resource file and I can't find a working solution. I've worked with the official <a href="https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/localization" rel="nofollow noreferrer">Xamarin Tutorial</a> and the <a href="https://github.com/conceptdev/xamarin-samples/tree/master/TaskyL10n" rel="nofollow noreferrer">example App</a>.
  It's a xamarin forms project and I want the app to show in german/english. The ios part works already.</p>
  <p>What I have so far:</p>
  <p>My Language-Files in the following folder structure:</p>
  <p>Resources &gt; values &gt; Strings.xml</p>
  <p>Resources &gt; values-de &gt; Strings.xml</p>
  <p>Strings.xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;resources&gt;
    &lt;string name=&quot;barcodescanner_toptext&quot;&gt;QR-Code Scanner&lt;/string&gt;
    &lt;string name=&quot;barcodescanner_bottomtext&quot;&gt;Please scan QR-Code.&lt;/string&gt;
    &lt;string name=&quot;barcodescanner_cancelbuttontext&quot;&gt;Cancel&lt;/string&gt;
    &lt;string name=&quot;barcodescanner_flashbuttontext&quot;&gt;Flash&lt;/string&gt;
    &lt;string name=&quot;barcodescanner_errortext&quot;&gt;Scan canceled&lt;/string&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>The property &quot;Build Action&quot; of the Strings.xml files are set to &quot;AndroidResource&quot;. In the Resource.Designer.cs the strings are visible.</p>
  <pre><code>// aapt resource value: 0x7f070041
  public const int barcodescanner_bottomtext = 2131165249;
          
  // aapt resource value: 0x7f070042
  public const int barcodescanner_cancelbuttontext = 2131165250;
          
  // aapt resource value: 0x7f070044
  public const int barcodescanner_errortext = 2131165252;
          
  // aapt resource value: 0x7f070043
  public const int barcodescanner_flashbuttontext = 2131165251;
          
  // aapt resource value: 0x7f070040
  public const int barcodescanner_toptext = 2131165248;
  </code></pre>
  <p>Inside of my Scanner.cs file I make the call like in the tutorial:</p>
  <pre><code>BarcodeScanner.TopText = Resources.System.GetText(Resource.String.barcodescanner_toptext);
  </code></pre>
  <p>I have to use &quot;.System.&quot; because there is no &quot;GetText&quot; directly on Resources. If I press &quot;.&quot; after Resource.String I get all my resourcestrings to select. But if I run the app on android I get the following error:</p>
  <blockquote>
  <p>No known package when getting value for resource number 0x7f070040</p>
  <p>System.TypeInitializationException: The type initializer for 'xyz.ViewModels.MainViewModel' threw an exception. ---&gt; System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; Android.Content.Res.Resources+NotFoundException: String resource ID #0x7f070040</p>
  </blockquote>
  <p>What I've done so far:</p>
  <ul>
  <li>cleaned and rebuild the solution</li>
  <li>deleted the obj and bin folders</li>
  <li>restarted all including my computer</li>
  <li>deinstalled the app from the smartphone</li>
  </ul>
  <p>I don't know what I should do next?
  Thanks for your help!</p>
  <p><strong>EDIT:</strong>
  If it's something useful, Visual Studio shows me on this part &quot;Resource.String.<em>barcodescanner_toptext</em>&quot; the following message: &quot;Ambiguous reference: int barcodescanner_toptext (in class String) int barcodescanner_toptext (in class String) match&quot;</p>