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

  • Question

  • User230948 posted

    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 BitmapStubeither:

    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 BitmapStubremains 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

    Friday, June 3, 2016 3:39 PM

All replies

  • User239 posted

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

    Tuesday, July 12, 2016 1:58 PM
  • User343509 posted

    Anyone solve this issue, i have the same issue.

    Saturday, July 6, 2019 6:48 AM