Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: listener not registered #40

Open
Liberations opened this issue Oct 10, 2022 · 3 comments
Open

java.lang.IllegalArgumentException: listener not registered #40

Liberations opened this issue Oct 10, 2022 · 3 comments

Comments

@Liberations
Copy link

E/AndroidRuntime( 553): FATAL EXCEPTION: NsdManager
E/AndroidRuntime( 553): Process: vip.mymei.remote, PID: 553
E/AndroidRuntime( 553): java.lang.IllegalArgumentException: listener not registered
E/AndroidRuntime( 553): at com.android.internal.util.Preconditions.checkArgument(Preconditions.java:59)
E/AndroidRuntime( 553): at android.net.nsd.NsdManager.getListenerKey(NsdManager.java:496)
E/AndroidRuntime( 553): at android.net.nsd.NsdManager.stopServiceDiscovery(NsdManager.java:636)
E/AndroidRuntime( 553): at com.nimroddayan.flutternsd.FlutterNsdPlugin$discoveryListener$1.onStartDiscoveryFailed(FlutterNsdPlugin.kt:195)
E/AndroidRuntime( 553): at android.net.nsd.NsdManager$ServiceHandler.handleMessage(NsdManager.java:412)
E/AndroidRuntime( 553): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 553): at android.os.Looper.loopOnce(Looper.java:233)
E/AndroidRuntime( 553): at android.os.Looper.loop(Looper.java:334)
E/AndroidRuntime( 553): at android.os.HandlerThread.run(HandlerThread.java:67)
I/Process ( 553): Sending signal. PID: 553 SIG: 9

@Nimrodda
Copy link
Owner

Thanks for the report. I need more info. What plugin version? Android version? When did it happen? Is this the full stacktrace? how to reproduce?

@vladotesanovic
Copy link

vladotesanovic commented Aug 6, 2023

Hi Nimrodd,

Same problem to me:

Plugin version: Private fork based on current master branch ( because current 1.3.3 does not have kotlin_version update )
Android version: 13
Phone: Google Pixel 6

Code to repoduce ( basic example )

@override
  Widget build(BuildContext context, WidgetRef ref) {
    final site = ref.watch(getSiteProvider);
    final flutterNsd = FlutterNsd();
    flutterNsd.stream.listen((nsdServiceInfo) {
      print('Discovered service name: ${nsdServiceInfo.name}');
      print('Discovered service hostname/IP: ${nsdServiceInfo.hostname}');
      print('Discovered service port: ${nsdServiceInfo.port}');
    }, onError: (e) {
      if (e is NsdError) {
        // Check e.errorCode for the specific error
      }
    });

    void startDiscoveryButton() async {
      await flutterNsd.discoverServices('_lisa._tcp.local.');
    }
Where startDiscoveryButton is triggered by:
    TextButton(
            style: ButtonStyle(
              foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
              overlayColor: MaterialStateProperty.resolveWith<Color?>(
                (Set<MaterialState> states) {
                  if (states.contains(MaterialState.hovered))
                    return Colors.blue.withOpacity(0.04);
                  if (states.contains(MaterialState.focused) ||
                      states.contains(MaterialState.pressed))
                    return Colors.blue.withOpacity(0.12);
                  return null; // Defer to the widget's default.
                },
              ),
            ),
            onPressed: () {
              startDiscoveryButton();
            },
            child: Text('Discover'),
      Full stack trace:
          `E/AndroidRuntime(15051): FATAL EXCEPTION: NsdManager
E/AndroidRuntime(15051): Process: my.package.enduser.home, PID: 15051
E/AndroidRuntime(15051): java.lang.IllegalArgumentException: listener not registered
E/AndroidRuntime(15051): 	at android.net.nsd.NsdManager.getListenerKey(NsdManager.java:980)
E/AndroidRuntime(15051): 	at android.net.nsd.NsdManager.stopServiceDiscovery(NsdManager.java:1224)
E/AndroidRuntime(15051): 	at com.nimroddayan.flutternsd.FlutterNsdPlugin$discoveryListener$1.onStartDiscoveryFailed(FlutterNsdPlugin.kt:195)
E/AndroidRuntime(15051): 	at android.net.nsd.NsdManager$ServiceHandler.lambda$handleMessage$1(NsdManager.java:856)
E/AndroidRuntime(15051): 	at android.net.nsd.NsdManager$ServiceHandler$$ExternalSyntheticLambda9.run(Unknown Source:6)
E/AndroidRuntime(15051): 	at android.net.nsd.NsdManager$$ExternalSyntheticLambda0.execute(Unknown Source:0)
E/AndroidRuntime(15051): 	at android.net.nsd.NsdManager$ServiceHandler.handleMessage(NsdManager.java:856)
E/AndroidRuntime(15051): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(15051): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(15051): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(15051): 	at android.os.HandlerThread.run(HandlerThread.java:67)
I/Process (15051): Sending signal. PID: 15051 SIG: 9`

@Nimrodda Nimrodda reopened this Aug 6, 2023
Nimrodda added a commit that referenced this issue Aug 6, 2023
@Nimrodda
Copy link
Owner

Nimrodda commented Aug 6, 2023

@vladotesanovic can you try the fix from this commit and tell me if it helps?

Nimrodda added a commit that referenced this issue Aug 8, 2023
@Nimrodda Nimrodda reopened this Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants