For some reason in my Android project when i added this component and nuget package to my PCL I am getting 151 errors similar to the below errors when I compile.
Severity Code Description Project File Line Suppression State
Error 'Resource.Attribute' does not contain a definition for 'mediaRouteSettingsDrawable' Elead.Mobile.Platform.Android C:\git\elead\CRMM\src\ELead.Mobile.Platform.Android\Resources\Resource.Designer.cs 221
Error 'Resource.Color' does not contain a definition for 'design_textinput_error_color' Elead.Mobile.Platform.Android C:\git\elead\CRMM\src\ELead.Mobile.Platform.Android\Resources\Resource.Designer.cs 371
Error 'Resource.Dimension' does not contain a definition for 'design_fab_content_size' Elead.Mobile.Platform.Android C:\git\elead\CRMM\src\ELead.Mobile.Platform.Android\Resources\Resource.Designer.cs 479
Error 'Resource.Dimension' does not contain a definition for 'design_navigation_padding_top_default' Elead.Mobile.Platform.Android C:\git\elead\CRMM\src\ELead.Mobile.Platform.Android\Resources\Resource.Designer.cs 489
Error 'Resource.Dimension' does not contain a definition for 'design_tab_min_width' Elead.Mobile.Platform.Android C:\git\elead\CRMM\src\ELead.Mobile.Platform.Android\Resources\Resource.Designer.cs 502
Any ideas? I am guessing there is a android target mismatch. Or something similar.
Thanks,
Bob
@Bobisback I believe this is the same bug as indicated here. Please comment here, so we can get this prioritized and fixed. https://bugzilla.xamarin.com/show_bug.cgi?id=39910
Is it possible to compile this project with the newest support library from android?
This is a big issue and it is causing a lot of headaches for many Nuget packages. Here is the XLabs discussion. The owners are working to recompile as we speak and release with the XF 2.3 update. The owner of this package will have to do the same. https://github.com/XLabs/Xamarin-Forms-Labs/issues/1125
I struggling all day today with the same errors in the Resource.Designer.cs. I have zxing 2.0.4.46 with Xforms 2.2.0.45 is there a workaround?
@xalikoutis so far the only workaround that I managed to make it work is simply add all the missing constants... Have a look at https://docs.google.com/document/d/12PcMIxAhKz0HCf4ZMhlC8TfKPagDub_5EMJtHaToYXo/edit – it has all the missing constants in one place so it's pretty eay to add.
However, you must do every time after build. So what I did is create a file Resource.designer.cs.bak and then copy it over $ cp Resource.designer.cs.bak Resource.designer.cs after I change anything.
Terrible, I know, but otherwise I guess we must wait for @Redth to recompile the package.
And so i did, i deleted the error lines, copied the code to an in memory file of notepad++ and every time before build i paste it inside Resource.Designer.cs. The best workaround so far.
@xalikoutis @CremboC @faceoffers28 My work around was pretty simple and work really well for my case but may not work for other people. I just used the non Xamarin Forms version of the library, it compiles, runs, and scans just fine. It turns out I only need the android version anyway so this really worked out for me.
If you need both though it would be really easy to create a custom control with a customer renderer for both iOS and Android and wire up the properties of both. You would get very similar functionality to what the forms version does. The hardest part would be if you need a custom overlay that is when the forms version would get hard. In my case I am perfectly happy with the default overlay so.
Edit: for mistake
@Bobisback Can you provide a little more detail as to exactly what you did? I assume that you have to somehow manually reference the non-Xamarin.Forms ZXing.Net.Mobile DLLs in your Android project. Thanks in advance!
@faceoffers28 Ya so I went to the component store in visual studio in my android project (not sure where this is in xamarin studio)

Then I installed the ZXing.Net.Mobile component. Aka not the ZXing.Net.Mobile for Forms.

Technically you could rinse and repeat for the iOS version as well. Below is the code for the android version I did. I also wrote a parser that converts the PDF417 barcode info to a dictionary I can access.
[assembly: ExportRenderer(typeof(LicenseScannerView), typeof(LicenseScannerRenderer))]
namespace Android.CustomRenderers
{
public class LicenseScannerRenderer : PageRenderer
{
private LicenseScannerView page;
private MobileBarcodeScanner scanner;
protected override async void OnElementChanged(ElementChangedEventArgs<Page> e)
{
base.OnElementChanged(e);
page = e.NewElement as LicenseScannerView;
// this is a ViewGroup - so should be able to load an AXML file and FindView<>
var activity = Context as Activity;
if (activity == null || page == null)
{
return;
}
page.StopLoading();
var options = new ZXing.Mobile.MobileBarcodeScanningOptions
{
PossibleFormats = new List<ZXing.BarcodeFormat>()
{
BarcodeFormat.PDF_417
}
};
scanner = new ZXing.Mobile.MobileBarcodeScanner();
scanner.TopText = "Hold your phone up to the barcode on back of license";
scanner.BottomText = "Scanning will happen automatically";
var result = await scanner.Scan(options);
//scanner.ScanContinuously(options, result => page.GotScanResultAndroid(result.Text));
page.GotScanResultAndroid(result == null ? string.Empty : result.Text);
}
}
}
And with fairly little work you could create a custom renderer for iOS as well, and create bind-able properties for all the fields in the scanner. These properties would go into your CustomControl that is called by these renderers. (In my case my custom control is a page, aka LicenseScannerView) This would afford you almost the same functionality as the current xamarin forms version. I have some free time today I could probably get that going pretty easily. Like I said the issue comes in if you want a custom overlay. It would get messy at that point. Really though there is probably nothing stopping us from just openning the ZXing forms dll and copying the renderers he made in that into our project lol.
Hope this helps!
P.S Sorry I have some extra code in that sample that is not needed. You will not be able to copy and paste directly. It will need some work, but it should give you an idea of how I did it.
Edit: I will try to post a more complete solution in a little bit.
@Bobisback This is great! I've only been developing for less than a year and working with Xamarin for even less, so some of these workarounds people come up with are a little over my head at this point. I understand the concepts, but I need the specifics in most cases. I see that you are looking at providing a more complete solution, so I will be on the lookout for that. I've got XZing.Net.Mobile working in my iOS project, so the custom overlay is fine by me. I just want it to work in Android. My PCL targets 259, so I've managed to get all my components and code working across so many devices. This is really the last piece to the puzzle for me.
@faceoffers28 ya if you have never done a custom control before they are pretty daunting, but once you do one they are great. I have like 60 custom controls that I use on a daily basis to help make coding easier by reusing controls that I use alot. I am commenting my code now so I can commit my changes (As I got it working like I want) as soon as I finish that I will spin up a sample project with what I am talking about. If you do not need iOS then my solution should work pretty well for you depending on how you are calling the iOS side of things. I am guessing you are not using custom renderers?
Has anyone tried the prerelease version which should fix this?
^^^^ in that case, not going to worry about doing anything more about this. Did not realize there was a fix in the prerelease for this. For the record I have not tried the prerelease version, but since I already got working what I needed I do not really have a reason to update and try it.
Thanks Redth for the work you have done on this project!
See ya,
Bob
@Redth Pre-release available via NuGet pkg?
No need to go with the Resource.Designer.cs. Just add the missing entries into partial classes, like this:
using System;
namespace MyProject.Droid
{
public partial class Resource
{
public partial class Attribute
{
public const int mediaRouteSettingsDrawable = -2;
}
public partial class Color
{
public const int design_textinput_error_color = -1;
}
public partial class Dimension
{
public const int design_fab_content_size = -1;
public const int design_navigation_padding_top_default = -1;
public const int design_tab_min_width = -1;
public const int dialog_fixed_height_major = -1;
public const int dialog_fixed_height_minor = -1;
public const int dialog_fixed_width_major = -1;
public const int dialog_fixed_width_minor = -1;
public const int mr_media_route_controller_art_max_height = -1;
}
public partial class Drawable
{
public const int ic_setting_dark = -1;
public const int ic_setting_light = -1;
public const int mr_ic_settings_dark = -1;
public const int mr_ic_settings_light = -1;
}
public partial class Id
{
public const int art = -1;
public const int buttons = -1;
public const int default_control_frame = -1;
public const int media_route_control_frame = -1;
public const int media_route_list = -1;
public const int media_route_volume_layout = -1;
public const int media_route_volume_slider = -1;
public const int play_pause = -1;
public const int route_name = -1;
public const int settings = -1;
public const int stop = -1;
public const int subtitle = -1;
public const int title_bar = -1;
public const int disconnect = -1;
}
public partial class Layout
{
public const int mr_media_route_chooser_dialog = -1;
public const int mr_media_route_controller_material_dialog_b = -1;
public const int mr_media_route_list_item = -1;
}
public partial class String
{
public const int mr_media_route_chooser_dialog = -1;
public const int mr_media_route_controller_material_dialog_b = -1;
public const int mr_media_route_list_item = -1;
public const int mr_media_route_button_content_description = -1;
public const int mr_media_route_chooser_searching = -1;
public const int mr_media_route_chooser_title = -1;
public const int mr_media_route_controller_disconnect = -1;
public const int mr_media_route_controller_no_info_available = -1;
public const int mr_media_route_controller_pause = -1;
public const int mr_media_route_controller_play = -1;
public const int mr_media_route_controller_settings_description = -1;
public const int mr_media_route_controller_stop = -1;
//public const int ApplicationName = -1;
//public const int Hello = -1;
}
public partial class Style
{
public const int RtlOverlay_Widget_AppCompat_ActionButton_Overflow = -1;
}
public partial class Styleable
{
public const int FloatingActionButton_android_background = -1;
public const int[] Theme = null;
public const int Theme_actionBarDivider = -1;
public const int Theme_actionBarItemBackground = -1;
public const int Theme_actionBarPopupTheme = -1;
public const int Theme_actionBarSize = -1;
public const int Theme_actionBarSplitStyle = -1;
public const int Theme_actionBarStyle = -1;
public const int Theme_actionBarTabBarStyle = -1;
public const int Theme_actionBarTabStyle = -1;
public const int Theme_actionBarTabTextStyle = -1;
public const int Theme_actionBarTheme = -1;
public const int Theme_actionBarWidgetTheme = -1;
public const int Theme_actionButtonStyle = -1;
public const int Theme_actionDropDownStyle = -1;
public const int Theme_actionMenuTextAppearance = -1;
public const int Theme_actionMenuTextColor = -1;
public const int Theme_actionModeBackground = -1;
public const int Theme_actionModeCloseButtonStyle = -1;
public const int Theme_actionModeCloseDrawable = -1;
public const int Theme_actionModeCopyDrawable = -1;
public const int Theme_actionModeCutDrawable = -1;
public const int Theme_actionModeFindDrawable = -1;
public const int Theme_actionModePasteDrawable = -1;
public const int Theme_actionModePopupWindowStyle = -1;
public const int Theme_actionModeSelectAllDrawable = -1;
public const int Theme_actionModeShareDrawable = -1;
public const int Theme_actionModeSplitBackground = -1;
public const int Theme_actionModeStyle = -1;
public const int Theme_actionModeWebSearchDrawable = -1;
public const int Theme_actionOverflowButtonStyle = -1;
public const int Theme_actionOverflowMenuStyle = -1;
public const int Theme_activityChooserViewStyle = -1;
public const int Theme_alertDialogButtonGroupStyle = -1;
public const int Theme_alertDialogCenterButtons = -1;
public const int Theme_alertDialogStyle = -1;
public const int Theme_alertDialogTheme = -1;
public const int Theme_android_windowAnimationStyle = -1;
public const int Theme_android_windowIsFloating = -1;
public const int Theme_autoCompleteTextViewStyle = -1;
public const int Theme_borderlessButtonStyle = -1;
public const int Theme_buttonBarButtonStyle = -1;
public const int Theme_buttonBarNegativeButtonStyle = -1;
public const int Theme_buttonBarNeutralButtonStyle = -1;
public const int Theme_buttonBarPositiveButtonStyle = -1;
public const int Theme_buttonBarStyle = -1;
public const int Theme_buttonStyle = -1;
public const int Theme_buttonStyleSmall = -1;
public const int Theme_checkboxStyle = -1;
public const int Theme_checkedTextViewStyle = -1;
public const int Theme_colorAccent = -1;
public const int Theme_colorButtonNormal = -1;
public const int Theme_colorControlActivated = -1;
public const int Theme_colorControlHighlight = -1;
public const int Theme_colorControlNormal = -1;
public const int Theme_colorPrimary = -1;
public const int Theme_colorPrimaryDark = -1;
public const int Theme_colorSwitchThumbNormal = -1;
public const int Theme_controlBackground = -1;
public const int Theme_dialogPreferredPadding = -1;
public const int Theme_dialogTheme = -1;
public const int Theme_dividerHorizontal = -1;
public const int Theme_dividerVertical = -1;
public const int Theme_dropDownListViewStyle = -1;
public const int Theme_dropdownListPreferredItemHeight = -1;
public const int Theme_editTextBackground = -1;
public const int Theme_editTextColor = -1;
public const int Theme_editTextStyle = -1;
public const int Theme_homeAsUpIndicator = -1;
public const int Theme_listChoiceBackgroundIndicator = -1;
public const int Theme_listDividerAlertDialog = -1;
public const int Theme_listPopupWindowStyle = -1;
public const int Theme_listPreferredItemHeight = -1;
public const int Theme_listPreferredItemHeightLarge = -1;
public const int Theme_listPreferredItemHeightSmall = -1;
public const int Theme_listPreferredItemPaddingLeft = -1;
public const int Theme_listPreferredItemPaddingRight = -1;
public const int Theme_panelBackground = -1;
public const int Theme_panelMenuListTheme = -1;
public const int Theme_panelMenuListWidth = -1;
public const int Theme_popupMenuStyle = -1;
public const int Theme_popupWindowStyle = -1;
public const int Theme_radioButtonStyle = -1;
public const int Theme_ratingBarStyle = -1;
public const int Theme_searchViewStyle = -1;
public const int Theme_selectableItemBackground = -1;
public const int Theme_selectableItemBackgroundBorderless = -1;
public const int Theme_spinnerDropDownItemStyle = -1;
public const int Theme_spinnerStyle = -1;
public const int Theme_switchStyle = -1;
public const int Theme_textAppearanceLargePopupMenu = -1;
public const int Theme_textAppearanceListItem = -1;
public const int Theme_textAppearanceListItemSmall = -1;
public const int Theme_textAppearanceSearchResultSubtitle = -1;
public const int Theme_textAppearanceSearchResultTitle = -1;
public const int Theme_textAppearanceSmallPopupMenu = -1;
public const int Theme_textColorAlertDialogListItem = -1;
public const int Theme_textColorSearchUrl = -1;
public const int Theme_toolbarNavigationButtonStyle = -1;
public const int Theme_toolbarStyle = -1;
public const int Theme_windowActionBar = -1;
public const int Theme_windowActionBarOverlay = -1;
public const int Theme_windowActionModeOverlay = -1;
public const int Theme_windowFixedHeightMajor = -1;
public const int Theme_windowFixedHeightMinor = -1;
public const int Theme_windowFixedWidthMajor = -1;
public const int Theme_windowFixedWidthMinor = -1;
public const int Theme_windowMinWidthMajor = -1;
public const int Theme_windowMinWidthMinor = -1;
public const int Theme_windowNoTitle = -1;
}
}
}
As soon as the problem is fixed, get rid of the file and you're fine.
Cheers.
Silver.
i was able to add the current pre-release to my PCL project but it failed when I tried adding the nuget (2.1.0-beta 1) to my droid package with this text in the package manager console:
Adding ZXing.Net.Mobile.Forms...
Attempting to resolve dependency 'ZXing.Net.Mobile (≥ 2.1.0-beta1)'.
Attempting to resolve dependency 'Xamarin.Android.Support.v4 (≥ 23.0.1.3)'.
Attempting to resolve dependency 'Xamarin.Forms (≥ 2.0.0.6490)'.
Attempting to resolve dependency 'Xamarin.Android.Support.v4 (= 23.0.1.3)'.
Already referencing a newer version of 'Xamarin.Android.Support.v4'.
I have XF 2.2.0.45 and the Xamarin.Android.Support.v4 is 23.3.0, which is why this is failing, I suppose.
Should I be using the ZXing component from the component store in my platform projects rather than the nugets?
I tried 2.1.0-beta 1 and it works fine immediately - no errors whatsoever. I got mine via NuGet.
I tried adding the components (2.0.4.17) in my platform projects and the build fails with all of the resource errors as noted above.
@CremboC what version of xamarin forms do you have? which versions of the android support libraries? which exact packages did you install into which projects?
@mrbelk I am using the following:
Xamarin.Forms: 2.2.0.45
ZXing.Net.Mobile: 2.1.0-beta1
ZXing.Net.Mobile.Forms: 2.1.0-beta1
And in Android:
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Forms" version="2.2.0.45" targetFramework="MonoAndroid60" />
<package id="ZXing.Net.Mobile" version="2.1.0-beta1" targetFramework="MonoAndroid60" />
<package id="ZXing.Net.Mobile.Forms" version="2.1.0-beta1" targetFramework="MonoAndroid60" />
@CremboC interesting. I'll give it another shot.
It worked this time. I hate computers.
Pre-release worked for me. Thanks for pushing out a fix, @Redth .
Android SDK Build-Tools 24 was the roadblock for me on this issue.
after downgrading to 23.anything "and" updating to the 2.1.0-beta1 of ZXing; I hadn't tried both those things at the same time yesterday :-/ I am at last able to get my Android project to build...and it even ran this time :-)
for reference I'm just a Xamarin.Forms version ahead of the chap above:
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Forms" version="2.3.0.49" targetFramework="monoandroid60" />
<package id="ZXing.Net.Mobile" version="2.1.0-beta1" targetFramework="monoandroid60" />
<package id="ZXing.Net.Mobile.Forms" version="2.1.0-beta1" targetFramework="monoandroid60" />
I can confirm that Zxing.Net.Mobile (2.1.0-beta1) is now working in my Xamarin.Forms (Portable PCL 259) Android Project (23 SDK). I had to Reference the new DLLs in my Portable, but the Nuget Packages installed just fine into my Android Project. My test device is a Samsung Galaxy S3, running API 19. Hope this helps. I have not tested my iOS app, but it was working just fine.
This will be fixed in the next major release. As indicated in a few places, it works in the prerelease project now :)
Most helpful comment
No need to go with the Resource.Designer.cs. Just add the missing entries into partial classes, like this:
As soon as the problem is fixed, get rid of the file and you're fine.
Cheers.
Silver.