Xamarin .jar binding - 'Bitmap could not be found'

vojtavojta CZMember

I have a .jar file with a Java interface called MyService, which has a method:

boolean printBitmapObject(android.graphics.Bitmap bitmap, byte[] result);

I would like to use this .jar file in C# in my Android Xamarin project in Visual Studio 2015. I did following steps:

!. I created a new library binding project.
2. I put the .jar file into Jars directory of the new project with BuildAction property set to InputJar.
3. The project was built successfully.
4. I added reference to the library binding project into my main project.

Unfortunately, I cannot build my main project anymore, because there is an error in the auto-generated C# code:

    public interface IMyService : global::Android.OS.IInterface
    {
       bool PrintBitmapObject (Bitmap bmp, byte[] result); //"Bitmap" is red underlined
    }

with message "The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?)".

There is also an auto-generated abstract class IMyServiceStub, which also doesn't recognize Bitmap. Moreover, it doesn't know some auto-generated BitmapStub either:

public abstract class IMyServiceStub : global::Android.OS.Binder, global::Android.OS.IInterface, IMyService
{
    ...
    protected override bool OnTransact (int code, global::Android.OS.Parcel data, global::Android.OS.Parcel reply, int flags)
    {
        ...
        case TransactionPrintBitmapObject: {
                data.EnforceInterface (descriptor);
                Bitmap arg0 = default (Bitmap); //Bitmap red underlined
                arg0 = BitmapStub.AsInterface (data.ReadStrongBinder ()); //BitmapStub red underlined
                byte [] arg1 = default (byte []);
                var result = this.PrintBitmapObject (arg0, arg1);
                reply.WriteNoException ();
                reply.WriteInt (result ? 1 : 0);
                data.WriteByteArray (arg1);
                return true;
                }
        ...
    }

}

I tried adding using Bitmap = Android.Graphics.Bitmap to the auto-generated file, but it doesn't help, because BitmapStub remains unknown and my changes are overwritten during the next build.

Is there anything I can do to fix this issue? Or is it a know bug in Xamarin (I use version 4.0)?

I also asked the same question on Stack Overflow: http://stackoverflow.com/questions/37616794/xamarin-jar-binding-bitmap-could-not-be-found

Answers

  • HuGuangYuHuGuangYu CNBeta

    I have the same issue while try to using AIDL which need to use BitmapStub.

  • DeepakDYDeepakDY INMember ✭✭✭

    Anyone solve this issue, i have the same issue.

Sign In or Register to comment.