Repository: flutter
Issue: multicast_dns 0.3.2+1 is not working on Android
Labels: package,p: multicast_dns,team-ecosystem,has reproducible steps,P2,found in release: 3.0,found in release: 3.1,triaged-ecosystem

## Steps to Reproduce

1. I'm following the example code to discover services in my local network
2. Execute `flutter run` on the code sample <!-- (see "Code sample" section below) -->
3. Press the floating action button to discover services

**Expected results:** <!-- what did you want to see? -->
There should be some text displaying the discovered services.

**Actual results:** <!-- what did you see? -->
1. On my Samsung Galaxy tablet running Android 12, services were found and displayed 
![image](https://user-images.githubusercontent.com/55541791/172455915-9738eefe-c7fb-4382-b00f-a716bca35ef3.png)
2. However, on my emulator and Google Pixel 3a running Android 12, the services were not found at all.
![image](https://user-images.githubusercontent.com/55541791/172456150-19854cb7-b2b5-4f06-ba60-c35dffc1a916.png)


<details>
<summary>Code sample</summary>

```dart
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:multicast_dns/multicast_dns.dart';

void main() {
  runApp(const MyApp());
}

Future<String> findServices() async {
  String res = '';

  const String name = '_airplay._tcp.local';
  MDnsClient client;
  if (Platform.isAndroid) {
    var factory = (dynamic host, int port,
        {bool reuseAddress = true, bool reusePort = true, int ttl = 10000}) {
      print("Hostname $host");
      print("Port ${port.toString()}");
      return RawDatagramSocket.bind(host, port,
          reuseAddress: true, reusePort: false, ttl: ttl);
    };
    client = MDnsClient(rawDatagramSocketFactory: factory);
  } else {
    client = MDnsClient();
  }
  await client.start();

  await for (final PtrResourceRecord ptr in client
      .lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
    await for (final SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
        ResourceRecordQuery.service(ptr.domainName))) {
      final String bundleId = ptr.domainName;
      debugPrint('Dart observatory instance found at '
          '${srv.target}:${srv.port} for "$bundleId".');
      res += '${srv.target}:${srv.port}; ';
    }
  }
  client.stop();

  debugPrint('Done.');
  return res;
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _services = '';

  void _handlePressButton() async {
    String foundServices = await findServices();
    setState(() {
      _services = foundServices;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Found services:',
            ),
            Text(
              _services,
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _handlePressButton,
        tooltip: 'Find services',
        child: const Icon(Icons.search),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->
1. On my Galaxy Tab (where multicast_dns is working)

```
[  +45 ms] I/flutter (29640): Hostname 0.0.0.0
[        ] I/flutter (29640): Port 5353
[  +43 ms] I/flutter (29640): Hostname InternetAddress('127.0.0.1', IPv4)
[        ] I/flutter (29640): Port 5353
[   +2 ms] I/flutter (29640): Hostname InternetAddress('192.168.17.227', IPv4)
[        ] I/flutter (29640): Port 5353
[ +533 ms] I/flutter (29640): Dart observatory instance found at test-MacBook-Pro.local:7000 for "test’s MacBook Pro._airplay._tcp.local".
[   +3 ms] I/flutter (29640): Dart observatory instance found at test1-MacBook-Pro.local:7000 for "test1’s MacBook Pro._airplay._tcp.local".
[+4504 ms] I/flutter (29640): Done.
```

2. On my other devices (where multicast_dns is not working)

```
[+9389 ms] I/flutter ( 7353): Hostname 0.0.0.0
[        ] I/flutter ( 7353): Port 5353
[  +67 ms] I/flutter ( 7353): Hostname InternetAddress('127.0.0.1', IPv4)
[        ] I/flutter ( 7353): Port 5353
[   +7 ms] I/flutter ( 7353): Hostname InternetAddress('10.0.2.15', IPv4)
[        ] I/flutter ( 7353): Port 5353
[        ] I/flutter ( 7353): Hostname InternetAddress('10.0.2.16', IPv4)
[   +2 ms] I/flutter ( 7353): Port 5353
[+5104 ms] I/flutter ( 7353): Done.
[  +63 ms] D/EGL_emulation( 7353): app_time_stats: avg=2911.63ms min=10.23ms max=9463.10ms count=5
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->
`flutter analyze` output

```
Analyzing bug...                                                        
No issues found! (ran in 1.7s)
```

The only issue in `flutter doctor -v` output is that `Xcode - develop for iOS and macOS is not installed`
</details>