Search code examples
motorola-emdk

TargetInvocationException when instantiating object implementing IEMDKListener


I am trying to use the component "EMDK for Xamarin" published by Zebra in the Xamarin Component store.

Per the sample, I am implementing the EMDKManager.IEMDKListener interface on a class I've created.

When I instantiate the class, I get a Java.Lang.NoClassDefFoundError exception listed as the InnerException inside the TargetInvocationException exception being thrown.

When I try to step into the class constructor for the class I created, I noticed it crashes before the first line is executed.

Has anyone else experienced this runtime exception before? How do I avoid the NoClassDefFoundError exception?


Solution

  • I have run into that same error. The fix was adding a few attributes in my AssemblyInfo.cs file. The attributes allow the low level access to the EMDK installed on the device.

    [assembly: Android.App.UsesLibrary(Name = "com.symbol.emdk")] [assembly: Android.App.UsesPermission(Name = "com.symbol.emdk.permission.EMDK")]