pyjnius icon indicating copy to clipboard operation
pyjnius copied to clipboard

Any call to variant of overloaded function leads to jnius.jnius.JavaException: No methods matching your arguments, available: []

Open ghost opened this issue 5 years ago • 1 comments

While revamping something about handling the services part of python-for-android I ran into this pyjnius error which seems to be a bug when calling the following now changed function in as defined in my pull request:


    public static void start_service(
            String serviceTitle,
            String serviceDescription,
            String pythonServiceArgument
            ) {
        // This is the legacy call with less parameters!
        start_service(
            serviceTitle, serviceDescription, pythonServiceArgument, true
        );
    }

    public static void start_service(
            String serviceTitle,
            String serviceDescription,
            String pythonServiceArgument,
            boolean showForegroundNotification
            ) {

(the function is defined at this position: https://github.com/kivy/python-for-android/blob/7a7d8ee9ec3450c377c473e5a1b14b4db6932efa/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java#L368 )

The failing pyjnius call looks like this:

mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
mActivity.start_service(
    "PythonService",
    "My Service",
    "",
    False,
)

The call results in this error:

06-26 08:16:34.350  7350  7460 I python  :   File "jnius/jnius_export_class.pxi", line 1034, in jnius.jnius.JavaMultipleMethod.__call__
06-26 08:16:34.350  7350  7460 I python  : jnius.jnius.JavaException: No methods matching your arguments, available: []

This seems to be just wrong, and it looks like pyjnius simply didn't identify the function signature correctly for whatever reason. Is the overloading handling broken in some way?

Steps to reproduce:

  1. pip3 install https://github.com/JonasT/python-for-android/archive/fix_forced_service_foreground.zip
  2. Build an kivy app that has the following call (it doesn't need to actually have a service or any other reasonable setup, since that would fail AFTER this error occurs):
    mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
    mActivity.start_service("bla", "blubb, "", False)
  1. Run the app

ghost avatar Jun 26 '19 06:06 ghost

Ok I'm just realizing I have an override for a static method there, I assume that is probably the issue / what's not working right. I solved things differently now (by just avoiding doing that) so this is no longer anything urgent, but I'll leave the issue up so hopefully myself or someone else will get around to look at this on occasion

ghost avatar Jun 26 '19 08:06 ghost