Binding Android static method

I want to bind static methods from a non static class :

public class MyClass {
public static void init(Context context) {
....
}
}

but this class and its method doesn't appear in the generated dll.

Anyone know how to manage to expose these static methods ?

Answers

  • AgenduumAgenduum USMember ✭✭

    I am experiencing the exact same problem right now. Were you able to get this to work? Below is a class according to JD-GUI and the createFactory method does not appear at all in the Xamarin generated output:

    package com.company.api;
    
    import android.content.Context;
    
    public final class ComponentSuperFactory
    {
      public static IComponentFactory createFactory(Context context)
      {
        return new ComponentFactory(context);
      }
    }
    
  • AgenduumAgenduum USMember ✭✭

    Ah I just figured this out. In my case IComponentFactory was completely omitted in the output:

    1>BINDINGSGENERATOR : warning BG8503: Invalidating Com.Company.Api.IComponentFactory and all nested types because some of its methods were invalid.
    

    The root cause for me is hinted in the first warning I get...

    1>BINDINGSGENERATOR : warning BG8C00: For type Com.Company.Api.IWorker, base interface com.company.api.k does not exist.
    

    I haven't yet figured out why 'k' is missing. JD-GUI shows it is there in the JAR:

    package com.company.api;
    
    abstract interface k
    {
      public abstract void setPlugin(IWorkerPlugin paramIWorkerPlugin);
    
      public abstract IWorkerPlugin getWorkerPlugin();
    }
    

    Anyway, I only include this information in the case it helps somebody else with this problem in the future...

  • I had warnings during my binding and some dependancy couldn't be solved. So I fixed the warning and the method appeared !

Sign In or Register to comment.