Home > Software engineering >  xamarin.android Java.Lang.NoSuchMethodError
xamarin.android Java.Lang.NoSuchMethodError

Time:02-26

I have created a xamarin.android binding library via .aar that needs to be initialized. When I call the native Start method I get an error:

Java.Lang.NoSuchMethodError
no static method "Lpackage/name/SDK;.start(Landroid/content/Context;Lpackage/name/Configuration;)V".

Deleting folders bin and obj and rebuilding the project does not help. I also watched the file api.xml this method is there, and and I can refer to it. Removing or adding a method to Metadata.xml also doesn't help.

Any suggestions or thoughts?

CodePudding user response:

I've been looking for the root of the problem for a very long time, and apparently I found it. I looked through the classes.dex file and saw there that I don't have a SDK type, there is only a SDK$-CC type.

Class #0            -
  Class descriptor  : 'Lpackage/name/SDK$-CC;'
  Access flags      : 0x1011 (PUBLIC FINAL SYNTHETIC)
  Superclass        : 'Ljava/lang/Object;'
  Interfaces        -
  Static fields     -
  Instance fields   -
  Direct methods    -
    #0              : (in Lpackage/name/SDK$-CC;)
      name          : 'start'
      type          : '(Landroid/content/Context;Lpackage/name/SDK$Configuration;)V'
      access        : 0x0009 (PUBLIC STATIC)
      code          -
      registers     : 3
      ins           : 2
      outs          : 3
      insns size    : 6 16-bit code units
      catches       : (none)
      positions     : 
      locals        : 
  Virtual methods   -
  source_file_idx   : 8937 (SDK.kt)

I changed the name of the Register from [Register ("package/name/SDK", "", "Package.Name.INameInvoker")] to [Register ("package/name/SDK$-CC", "", "Package.Name.INameInvoker")].

The full explanation is here: https://github.com/xamarin/xamarin-android/issues/6784

  • Related