Epson ePOS SDK for Android (Xamarin) missing constants

2.3k Views Asked by At

We are trying to updgrade the SDK of epson, which is deprecated since a long while.

We were using the old ePOS-Print SDK (com.epson.eposprint) package and we began having problems with it, so we rightly decided to migrate to the current one, Epson ePOS SDK for Android (com.epson.epos2).

We are using Visual Studio Xamarin.

We followed the migration document included in the SDK. Replaced most of the code. But, it seems that either Xamarin has problem the java bindings or something is missing, because almost 90% of the enum values are not available. It's almost near impossible without the enum values to correctly call the methods... For example, we do have some of the enums available (like the BatteryLevelX, TMxx, Pattern*), but that's about it.

We are using Android 8.0

Our javabinding project is configured like that:

--JarLibrary
----Jars
-------ePOS2.jar
-------ePOSEasySelect.jar
----libs
------armeabi
--------libepos2.so
--------libeposeasyselect.so
------armeabi-v7a
--------libepos2.so
--------libeposeasyselect.so

Project Properties:

Android Class parser: jar2xml Android codegen target: XAJavaInterop1

Any ideas why this is?

EDIT : Solution is to make sure all objects with no visibility keywords in the SDK is fixed with the Metadata.xml Transforms file, this way:

<!-- On enlève l'ancienne classe du package qui ne sert plus à rien, juste pour la migration -->
<remove-node path="/api/package[starts-with(@name, 'com.epson.epsonio')]" />

<!-- Need to change the visibility of many ommited classes visibility in jar epos -->
<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='NativeDevice']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.commbox']/class[@name='NativeCommBox']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.commbox']/class[@name='NativeCommBoxManager']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.keyboard']/class[@name='NativeKeyboard']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.printer']/class[@name='NativePrinter']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.scanner']/class[@name='NativeScanner']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.simpleserial']/class[@name='NativeSimpleSerial']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='DeviceInnerImplement']"
      name="visibility">protected</attr>

<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='NativeDevice']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2.printer']/class[@name='CommonPrinter']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2.printer']/class[@name='LogoKeyCode']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2']/class[@name='NativeInitializer']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2']/class[@name='OutputLog']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.display']/class[@name='NativeDisplay']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='Device.DeleteDeviceCallbackAdapter']"
      name="visibility">protected</attr>
3

There are 3 best solutions below

0
On BEST ANSWER

EDIT : Solution is to make sure all objects with no visibility keywords in the SDK is fixed with the Metadata.xml Transforms file, this way:

<!-- On enlève l'ancienne classe du package qui ne sert plus à rien, juste pour la migration -->
<remove-node path="/api/package[starts-with(@name, 'com.epson.epsonio')]" />

<!-- Need to change the visibility of many ommited classes visibility in jar epos -->
<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='NativeDevice']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.commbox']/class[@name='NativeCommBox']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.commbox']/class[@name='NativeCommBoxManager']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.keyboard']/class[@name='NativeKeyboard']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.printer']/class[@name='NativePrinter']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.scanner']/class[@name='NativeScanner']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.simpleserial']/class[@name='NativeSimpleSerial']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='DeviceInnerImplement']"
      name="visibility">protected</attr>

<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='NativeDevice']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2.printer']/class[@name='CommonPrinter']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2.printer']/class[@name='LogoKeyCode']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2']/class[@name='NativeInitializer']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.epos2']/class[@name='OutputLog']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice.display']/class[@name='NativeDisplay']"
      name="visibility">public</attr>

<attr path="/api/package[@name='com.epson.eposdevice']/class[@name='Device.DeleteDeviceCallbackAdapter']"
      name="visibility">protected</attr>
1
On

The recommended solution to this binding problem is to remove the problem element rather than tweak the modifier (non-public to public) in the Transforms/Metadata.xml file. More details here from Microsoft Docs.

Example,

  • Remove the entire non-public class from the binding,

    <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
    
  • Remove just the non-public method from the binding,

    <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
    
1
On

For anyone still struggling with this, I've found a solution that seems to do the job without re-writing the library.

  1. In your solution, create a new "Android Bindings Library (Xamarin)" project.
  2. Add the ePOS2.jar (and ePOSEasySelect.jar if needed) file to the "Jars" folder and set the file's build action (in the properties window) to "EmbeddedJar".
  3. INSTALL THE OPOS Common Control Objects (CCOs) locally (OPOS_CCOs_1.14.001.msi) from the Epson ePOS SDK for Android download.
  4. Copy all of the resulting .dll files to your project from step 1. I've used a "lib" folder within it, but you do you.
  5. Reference the .dlls from the project.
  6. Build.

You should end up with a library you can reference from other projects and make use of the Com.Epson.Epos2 namespace and all the classes within it.

For reference, most of the useful constants are accessed through the Com.Epson.Eposdevice namespace. e.g. Com.Epson.Eposdevice.Printer.Printer.LangEn

Note: There is no default DiscoveryListener class, so you would need to build your own if you go down that route.

Also worth remembering most Java projects use camelCaseFormatting for their method names, so when copy/pasting examples from the documentation (which is woeful), don't forget to change your methods to TitleCaseFormatting.

Also, Also: I keep getting an error with global::Com.Epson.Epos2.Printer.LogoKeyCode not existing for whatever reason. A temporary solution is to add the following line to the MetaData.xml file in the Bindings Library's Transforms folder:

  <remove-node path="/api/package[@name='com.epson.epos2.printer']/class[@name='Printer']/method[@name='getLogoList' and count(parameter)=0]"/>