VS2017 and AIDL files

Hi

I'm completely new to Xamarin. I'm using VS2017 and I've included some AIDL files for a Sunmi V1 POS device. Eventually I need it to print to the device's thermal printer when a new order is received, but I'm struggling with the basics.

I've added the AIDL files and a Java class called TransBean (all provided by Sunmi), and I can see that when I build it, it's converted all this to C# classes. I have set the build action to AndroidInterfaceDescription for all AIDL files. Not sure what I should do for the Java file but I tried setting it to AndroidJavaSource but it didn't seem to help.

The Problem
But the generated TransBean.cs has no contents (not even the class definition). As a result, I'm getting build errors saying it can't find TransBean.

Just realised that I can't post screenshots, although I have a few that I can send (will try to describe instead)

The generated TransBean.cs file has no contents. I would have assumed it should contain a C# representation of the Java class.

The AIDL file for TransBean just looks like this

package com.sunmi.trans;

parcelable TransBean;

The TransBean.java file has lots of content e.g.

    package com.sunmi.trans;

    import android.os.Parcel;
    import android.os.Parcelable;

    public class TransBean implements Parcelable {

        private byte type = 0;
        private String text = "";
        private byte[] data = null;
        private int datalength = 0;

        public TransBean(){
            type = 0;
            data = null;
            text = "";
            datalength = 0;     
        };

This is the generated TransBean.cs file. As you can see, it's empty

    // This file is automatically generated and not supposed to be modified.
    using System;
    using Boolean = System.Boolean;
    using String = System.String;
    using List = Android.Runtime.JavaList;
    using Map = Android.Runtime.JavaDictionary;

    namespace Com.Sunmi.Trans
    {
    }

As a result, anything that needs to use it throws a build error (TransBean does not exist in the namespace), such as this line (also auto-generated from a different AIDL file I guess)

void CommitPrint (Com.Sunmi.Trans.TransBean [] transbean, ICallback callback);

In the above line,

Please could someone tell me what I'm doing wrong? I'm guessing when the C# file is being generated, the contents of the Java file is supposed to be converted into C# and inserted into the resulting .cs file but maybe it's not picking it up.

Thanks!

Posts

  • Sorry, I posted this three times because I was having a nightmare with my phone when I was trying to submit it. Moderators, please feel free to delete two of them, they are just duplicates of the same post.

  • conhojconhoj Member

    Did you manage to sole this I am having the same problem

  • richardgundersenrichardgundersen Member ✭✭
    I didn't sorry. I remember it being so frustrating. I think your best bet is to contact Sunmi support although they were a bit hit and miss when I tried contacting them. Hate to say it but I gave up in the end :(
  • johntsiljohntsil Member ✭✭

    I have these problem too and i couldnt found why TransBean.cs is empty. I suppose that must be a problem with the aidl files that provided by sunmi. My solution is:
    1) First you must find what functions needed by TransBean implementation
    2) Comment out this functions at the original aidl file (e.g. CommitPrint at IWoyouService)
    3) Build your project
    4) Find the .cs files from the aidl files (obj -> Debug -> 81 (or other android version) -> aidl)
    5) Add these files to your project and delete all aidl files
    6) Now you can build your project but without these functions that you comment. Personally i dont care about printing images just text. (For the V1S i must comment out CommitPrint and printBitmapCustom)

Sign In or Register to comment.