Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'warning BG8102: Class X has unknown base type Y' warning while binding java code in xamarin

I'm currently trying to get the SDK, that's written in java (.jar file), to work with Xamarin.Android. Therefore, I'm trying to bind the .jar file by following the official tutorial (https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-a-jar). How do I get rid of the warnings 'warning BG8102: Class X has unknown base type Y.' without having the source code ?

Unfortunately, I haven't had that much success, since only a small part of the classes would bind correctly. I looked into the console and saw a lot of similar warnings 'warning BG8102: Class Wangpos.Sdk4.Libbasebinder.IDCard has unknown base type wangpos.sdk4.libbasebinder.a.'. All of the other warning were mostly the same - only the classes differ (base type stays the same). I have tried dissasembling the .jar SDK files, however the base class 'a' doesn't seem out of the ordinary. No additional references except the java native ones.

A short snippet of the dissasembled class.


import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
import android.os.RemoteException;
import android.util.Log;
import java.util.concurrent.CountDownLatch;
import wangpos.sdk4.base.IBinderPool;


public class a
{
  private static final String a = "BaseBinder";
  public static final int BINDER_NONE = -1;
  private Context c;
  private static IBinderPool d = null;

  private static a e;
  private CountDownLatch f;
  protected boolean b = false;

  private a(Context context) {
    c = context;
    d = null;
    c();
  }


  public a() {}

  static a a(Context context)
  {
    if (d == null) {
      synchronized (a.class) {
        if (d == null) {
          e = new a(context);
        }
      }
    }
    return e;
  }

  private ServiceConnection g = new BaseBinder.1(this);
  ...
}

Corresponding section of the generated api.xml file:

    <class abstract="false" deprecated="not deprecated" extends="java.lang.Object" extends-generic-aware="java.lang.Object" jni-extends="Ljava/lang/Object;" final="true" name="a" static="false" visibility="public" jni-signature="Lsdk4/wangpos/libemvbinder/a;">
      <constructor deprecated="not deprecated" final="false" name="a" jni-signature="()V" bridge="false" static="false" type="sdk4.wangpos.libemvbinder.a" synthetic="false" visibility="public">
      </constructor>
      <field deprecated="not deprecated" final="true" name="a" jni-signature="Z" static="true" transient="false" type="boolean" type-generic-aware="boolean" visibility="public" volatile="false">
      </field>
      <field deprecated="not deprecated" final="true" name="b" jni-signature="Ljava/lang/String;" static="true" transient="false" type="java.lang.String" type-generic-aware="java.lang.String" value="&quot;sdk4.wangpos.libemvbinder&quot;" visibility="public" volatile="false">
      </field>
      <field deprecated="not deprecated" final="true" name="c" jni-signature="Ljava/lang/String;" static="true" transient="false" type="java.lang.String" type-generic-aware="java.lang.String" value="&quot;debug&quot;" visibility="public" volatile="false">
      </field>
      <field deprecated="not deprecated" final="true" name="d" jni-signature="Ljava/lang/String;" static="true" transient="false" type="java.lang.String" type-generic-aware="java.lang.String" value="&quot;&quot;" visibility="public" volatile="false">
      </field>
      <field deprecated="not deprecated" final="true" name="e" jni-signature="I" static="true" transient="false" type="int" type-generic-aware="int" value="1" visibility="public" volatile="false">
      </field>
      <field deprecated="not deprecated" final="true" name="f" jni-signature="Ljava/lang/String;" static="true" transient="false" type="java.lang.String" type-generic-aware="java.lang.String" value="&quot;1.3&quot;" visibility="public" volatile="false">
      </field>
    </class>

No corresponding .cs file is generated for this class.

UPDATE: Link to .jar SDK files, for everyone to try: https://www.dropbox.com/sh/msy3pa65x6u1ou7/AACb0rZBo3u3g33-XuRA7U6Ca?dl=0

Finally, the expected result would be a full or almost full SDK classes availability in c# as a result of .jar binding.

Since I'm new to java binding in xamarin, any tips are much appreciated.

like image 484
Jonas Petraška Avatar asked Oct 19 '25 06:10

Jonas Petraška


1 Answers

Typically we will see characteristics of obfuscated types in our respective .jar/.aar libraries and we must unobfuscate them for the Bindings Generator to generate the respective C# types.

you could try this,in your libarary - Transforms - Metadata.xml add:

<attr path="/api/package[@name='{package_name}']/class[@name='{name}']" name="obfuscated">false</attr>
like image 76
Leo Zhu - MSFT Avatar answered Oct 20 '25 20:10

Leo Zhu - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!