Search code examples
zxingxamarin.forms

Unknown globals when installing ZXing Scanner


I have a Xamarin.Forms project which needs a QR code scanner. I found ZXing Scanner which seems to be a well established library for such purposes.

I installed it in the corresponding android project which worked without errors. When I wanted to build the app, Resource.Designer.cs was adjusted with the following lines:

global::ZXing.Mobile.Resource.Id.contentFrame = global::my.project.Droid.Resource.Id.contentFrame;
global::ZXing.Mobile.Resource.Layout.zxingscanneractivitylayout = global::my.project.Droid.Resource.Layout.zxingscanneractivitylayout;
global::ZXing.Mobile.Resource.Layout.zxingscannerfragmentlayout = global::my.project.Droid.Resource.Layout.zxingscannerfragmentlayout;

The problem is that I as well get the following errors:

'my.project.Droid.Resource.Id' does not contain a definition for 'contentFrame' 
'my.project.Droid.Resource.Layout' does not contain a definition for 'zxingscanneractivitylayout'
'my.project.Droid.Resource.Layout' does not contain a definition for 'zxingscannerfragmentlayout'

I installed ZXing using NuGet but I as well tried to add the dlls manually. I get the same errors. Can anyone help me how to fix this?

Thank you in advance.


Solution

  • It's quite possible that your Resource.Designer.cs is not updating correctly:

    • Clean Project Build
    • Remove ZXing package.
    • Clean Project Build
    • Add ZXing package
    • Clean and Build Project once again

    If it won't help:

    https://kb.xamarin.com/customer/portal/articles/1638018-my-android-resource-designer-cs-file-will-not-update or https://forums.xamarin.com/discussion/13339/resource-designer-cs-not-regenerated/