0

I am wondering if someone can help me with my question about Xamarin apps.

Let's say I would have to develop an Android application in Xamarin. Because of the app's nature I would have to develop it as Xamarin Android since Xamarin Forms would not work with Zebra's EMDK(3rd party library). If Windows 10 mobile get's more traction there could be a requirement to use this application also on Windows phones.

How much of code that I would write for Xamarin Android could be reused in future for Xamarin Windows app? Has anyone ever done something similar?

Denis Vitez
  • 608
  • 11
  • 32
  • This really depends on your architecture, how much domain-logic and sharable ui logic your app contains and is very different from scenario to scenario. – Kai Brummund Mar 08 '16 at 15:02

2 Answers2

3

As a general rule of thumbs, you can expect to have to rewrite the views of your application if you're going to use an MVVM library.

What is not clear to me is why you can't use Zebra's EMDK for Xamarin with Xamarin Forms.
I've partners using it, here's a sample I've put together that explain the basics.

Disclaimer: I work for Zebra Technologies on the development tools

Note: I no longer work for Zebra
For question on Zebra's EMDKs a good option is Zebra's developer portal

pfmaggi
  • 6,116
  • 22
  • 43
  • Using the example that you have provided I was able to make barcode scanner work in my Xamarin.Forms application. Thank you. Could you perhaps help me with another question. Is it possible to make application that requires EMDK to also work on other devices that does not offer EMDK? So far every attempt to start my application on device with no EMDK has failed. – Denis Vitez Jun 02 '16 at 11:32
  • Hi Denis, having an app that use the EMDK but can run on a non Zebra device is totally possible. Take a look at this discussion on [Zebra's Launchpad](https://developer.zebra.com/thread/31800). BTW: We plan to have a workshop in Ljubljana in September. – pfmaggi Jun 02 '16 at 14:03
  • Hi, I was able to port code from provided answer into Xamarin and I can confirm that application is now working on non EMDK devices. I also had to change this line in AndroidManifest file: and set android:required flag to false. However application is now working on TC55 and non EMDK devices but barcode scanning is not working on TC70. Do I maybe have to change EMDKConfig.xml somehow? – Denis Vitez Jun 03 '16 at 10:11
  • Check to have the EMDK runtime installed on the Zebra devices (TC55 and TC70), everything else should be the same. – pfmaggi Jun 03 '16 at 15:39
  • Hi @pfmaggi, I have found a bug inside my application. I get null value for the following line: `mProfileManager = (ProfileManager)emdkManager.GetInstance(EMDKManager.FEATURE_TYPE.Profile);` I have double checked the sample code and my application and the code looks identical. Everything else works except profile is not being generated in DataWedge when I load my application on a device. Do you maybe have any idea why would I get null for ProfileManager? – Denis Vitez Jul 20 '16 at 12:49
  • Denis, what device are you using? which version of the EMDK? which EMDK Runtime do you have on your device? is the piece of code that fails on you inside the onOpened callback? – pfmaggi Jul 20 '16 at 13:13
  • I have EMDK for Xamarin version 2.0.4.3, EMDK servcice on device is 3.1.38 and the device is TC55 running 4.4.3 Android and yes the code is inside OnOpened, just like in your sample. – Denis Vitez Jul 20 '16 at 13:34
  • You need to install the new EMDK Runtime on the device. The version available with the new Xamarin EMDK should be around v5.x. Update it and let me know if you still see the problem. – pfmaggi Jul 20 '16 at 15:30
  • I updated the EMDK runtime using the "Install device runtime" feature inside Visual Studio it is now at version 4.1.2.0. However the problem remains the same. It is strange that everything else is working but I get null for ProfileManager. – Denis Vitez Jul 21 '16 at 07:57
  • Denis, would be helpful to have some code to look to understand what is going on. Without that is impossible to help. You can post a discussion on developer.zebra.com in the Android area if you want. – pfmaggi Jul 21 '16 at 13:35
  • Hi Pietro. I've the same issue, same device. I've updated the EMDK device runtime to 5. My code is your code, as I'm using the sample on your github. Null reference exception on mProfileManager = (ProfileManager)emdkManager.GetInstance(EMDKManager.FEATURE_‌​TYPE.Profile); – Dave Nov 01 '16 at 12:57
  • Hi Dave, I hate to say this, but: "it works on my device". I'm testing this on a TC55 2D GMS with [BSP 2.65 with CFE-02 installed](https://www.zebra.com/us/en/support-downloads/software/operating-system/tc55-operating-system.html). I've updated the project on github to include the latest EMDK component (the project originally included an Alpha version of the EMDK component) – pfmaggi Nov 02 '16 at 14:44
  • ...and I've done the same test on a TC55 1D (again BSP 2.65+CFE-02, GMS version, and EMDK v5.0.3). No issue even on this device. You can find the release apk I generated on my mac with Xamarin Studio v6.1.1, Xamarin.Android v7.0.1.3 and Xamarin Forms v2.3.2.127 [here](https://zebra.box.com/s/6rv5cdcz7apxomabtsx07ef8k3u36hvu) – pfmaggi Nov 03 '16 at 13:52
  • Hi Pietro, this is a late replay but still beter late than never. I managed to fix the problem. The problem was that the EMDK profile file was encoded as UTF-8 with BOM and not UTF-8 without BOM (or maybe it was the other was around I'm not 100% sure). Changing the file encoding fixed the problem. This was a strange bug indeed. Maybe you could add this file encoding check into EMDK, so it would return some kind of an error to notify developer about his problem :) – Denis Vitez Jun 03 '17 at 15:08
  • Thanks @DenisVitez, can you provide some additional information to reproduce the issue? thanks! – pfmaggi Sep 09 '17 at 14:36
  • Hi @pfmaggi, the procedure to reproduce this issue if fairly simple. Just open the EMDKConfig.xml file, that you are using in your testing app in some text editor (for example Notepad++) and change the encoding to "UTF-8-BOM" and save the file. After that if you try to build your app and deploy it to device, it will not create DataWedge profile that is defined inside EMDKConfig.xml file. If you change the file encoding back to "UTF-8" it will work again. Let me know if you will manage to reproduce it. – Denis Vitez Sep 14 '17 at 13:09
  • @pfmaggi Hi, I've just encountered this issue again, so I guess it haven't been fixed yet? It happend with EMDK for Xamarion 3.0. Why this happens is because Visual Studio will create the .xml with the UTF-8-BOM encoding by default, so I guess this is a common issue and I'm surprised it hasn't been fixed yet. Of course I know now to use the workaround and change the encoding of the file in Notepad++, but I would still prefer to see this fixed :) – Denis Vitez Jan 03 '19 at 15:44
  • @pfmaggi Oh I noticed you don't work for Zebra anymore. Sorry, I will contact the official support :) – Denis Vitez Jan 03 '19 at 15:46
  • Another option is to post your questions/suggestion on Zebra developer portal: https://developer.zebra.com – pfmaggi Jan 04 '19 at 08:21
0

Denis, Can you try with the info given here and see if it helps? UTF-8 without BOM

If you want to save a file with other encodings select save as and extend the save button in file dialog and select "Save with encoding". Or if you you want to get rid of this setting permanently just open File menu and select "Advanced save options" and there you should select "UTF-8 without signature" (and that also answered your last question :). Yes "UTF-8 without signature" is same as without BOM.

https://marketplace.visualstudio.com/items?itemName=SergeyVlasov.FixFileEncoding