Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Epson ePOS SDK for Android (Xamarin) missing constants

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?

Best Answer

  • dceedcee Member ✭✭
    Accepted Answer

    I had to edit the Metadata.xml file in the javabinding project, lots of classes and methods needed to be tweaked as for the access modifiers. Now its working.

Answers

  • dceedcee Member ✭✭

    Just to add to this, I opened the com.epson.epos2 with a java decompiler, and it seems the constants are in the abstract class CommonPrinter, that the Printer class inherits from. But, in the generated c# wrapper class, the printer class inherits only from global::Java.Lang.Object

    Is it a binding problem?

  • dceedcee Member ✭✭

    More on this:

    When I build, I also get multiple errors of missing types, it seems all abstract interfaces are also not being correctly bound, do I have to do something special in the Metadata.xml?

    For example, I have this .class in the package:

    package com.epson.epos2.cashchanger;
    
    import java.util.Map;
    
    public abstract interface CashCountListener
    {
        public abstract void onCChangerCashCount(CashChanger paramCashChanger, int paramInt, Map<String, Integer> paramMap);
    }
    

    When build the library, I get something like that:

    package mono.com.epson.epos2.cashchanger;
    
    
    public class CashCountListenerImplementor
        extends java.lang.Object
        implements
            mono.android.IGCUserPeer,
            com.epson.epos2.cashchanger.CashCountListener
    {
    /** @hide */
        public static final String __md_methods;
        static {
            __md_methods = 
                "n_onCChangerCashCount:(Lcom/epson/epos2/cashchanger/CashChanger;ILjava/util/Map;)V:GetOnCChangerCashCount_Lcom_epson_epos2_cashchanger_CashChanger_ILjava_util_Map_Handler:Com.Epson.Epos2.Cashchanger.ICashCountListenerInvoker, Teknome.JarLibrary\n" +
                "";
            mono.android.Runtime.register ("Com.Epson.Epos2.Cashchanger.ICashCountListenerImplementor, Teknome.JarLibrary", CashCountListenerImplementor.class, __md_methods);
        }
    
    
        public CashCountListenerImplementor ()
        {
            super ();
            if (getClass () == CashCountListenerImplementor.class)
                mono.android.TypeManager.Activate ("Com.Epson.Epos2.Cashchanger.ICashCountListenerImplementor, Teknome.JarLibrary", "", this, new java.lang.Object[] {  });
        }
    
    
        public void onCChangerCashCount (com.epson.epos2.cashchanger.CashChanger p0, int p1, java.util.Map p2)
        {
            n_onCChangerCashCount (p0, p1, p2);
        }
    
        private native void n_onCChangerCashCount (com.epson.epos2.cashchanger.CashChanger p0, int p1, java.util.Map p2);
    
        private java.util.ArrayList refList;
        public void monodroidAddReference (java.lang.Object obj)
        {
            if (refList == null)
                refList = new java.util.ArrayList ();
            refList.add (obj);
        }
    
        public void monodroidClearReferences ()
        {
            if (refList != null)
                refList.clear ();
        }
    }
    

    So, the build fails with this:

    Severity Code Description Project File Line Suppression State
    Error error: package com.epson.epos2.cashchanger does not exist
    com.epson.epos2.cashchanger.CashCountListener Teknome.XS.Droid D:\dev\TeknomeProjects\xService\Mobile\Sources\Main.NewEPOS\XService.Droid\obj\Debug\MonoAndroid80\android\src\mono\com\epson\epos2\cashchanger\CashCountListenerImplementor.java 8

  • JonathanPeelJonathanPeel USMember ✭✭

    @dcee I now seem to be having these problems now.
    Did you ever figure out what the issue was?

  • dceedcee Member ✭✭

    @JonathanPeel Sorry, we left it on the old format... stuck with the old SDK. Our next step when we have time to go into this will be to use the SDK in Android Studio, and then try to export ourselves a JAR correctly configured for Xamarin.

  • FersFers Member ✭✭

    @dcee Hi, I'm trying to use the old epson sdk but it doesn't work, I already binding the .JAR, but when I create and instance of the printer class I get the error NoClassDefFoundError, do you have any advise, how do you do the binding?

  • dceedcee Member ✭✭

    @Fers Epson released a new SDK this week, it still doesn't work, but it comes closer! Take a look , I had to ignore some enums, but it looks promising.

  • dceedcee Member ✭✭

    nevermind. still the same missing classes...

  • dceedcee Member ✭✭
    Accepted Answer

    I had to edit the Metadata.xml file in the javabinding project, lots of classes and methods needed to be tweaked as for the access modifiers. Now its working.

Sign In or Register to comment.