Skip to content

[Bug]: Adnroid Emulator on first start hasInternetAccess returns false #121

@umair9430

Description

@umair9430

Is there an existing issue for this?

  • I have searched the existing issues

Bug Description

When running the app on Android Emulator immediately after first install / cold start, my connectivity check (hasInternetAccess / isConnected) returns false, even though:
• WebSocket connects successfully
• Firebase initializes successfully
• Actual internet is clearly available

This behavior only occurs on Android Emulator.

On other platforms:
• ✅ Real Android device → works correctly
• ✅ iOS Simulator → works correctlysteps

Steps to Reproduce

1.	Cold boot Android Emulator
2.	Install the app (fresh install)
3.	Launch the app
4.	Wait for app initialization
•	Firebase connects
•	WebSocket connects
5.	Trigger connectivity check (hasInternetAccess / isConnected)
6.	Observe returned value

Expected Behavior

When the device/emulator has an active internet connection:
• hasInternetAccess / isConnected should return true
• Especially when other network services (WebSocket, Firebase) are already connected
• Behavior should be consistent across platforms:
• Android Emulator
• Real Android devices
• iOS Simulator

The first connectivity check after app install or cold start should not produce a false negative.

Actual Behavior

On Android Emulator (first app launch after fresh install or cold boot):
• hasInternetAccess / isConnected returns false
• At the same time:
• WebSocket connects successfully
• Firebase initializes successfully
• Retrying the same connectivity check or restarting the app returns true

This issue does not occur on real Android devices or iOS Simulator.

Package Version

2.9.1+2

Platform(s)

Android

Flutter Channel

stable

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.38.3, on macOS 15.3 24D60 darwin-arm64, locale en-PT) [611ms]
    • Flutter version 3.38.3 on channel stable at /Users/umair.k/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 19074d12f7 (2 months ago), 2025-11-20 17:53:13 -0500
    • Engine revision 13e658725d
    • Dart version 3.10.1
    • DevTools version 2.51.1
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0-rc4) [1,590ms]
    • Android SDK at /Users/umair.k/Library/Android/sdk
    • Emulator version 35.3.11.0 (build_id 12836668) (CL:N/A)
    • Platform android-36, build-tools 36.0.0-rc4
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
    • All Android licenses accepted.

Minimal Reproduction Code

sealed class InternetConnectivityGuard {
  Future<void> ensureConnectedToInternet();
}

class InternetConnectivityGuardImpl implements InternetConnectivityGuard {
  InternetConnectivityGuardImpl({
    required NetworkInfoService networkInfo,
  }) : _networkInfo = networkInfo;

  final NetworkInfoService _networkInfo;

  @override
  Future<void> ensureConnectedToInternet() async {
    final bool isConnected = await _networkInfo.isConnected;
    if (!isConnected) {
      final String message =
          getItInstance.isRegistered<InternetFailureMessage>()
              ? getItInstance<InternetFailureMessage>().text
              : _Constants.noInternetConnectionMessage;
      throw NoInternetException(
        message: message,
      );
    }
  }
}

sealed class NetworkInfoService {
  Future<bool> get isConnected;
}

class NetworkInfoServiceImpl implements NetworkInfoService {
  NetworkInfoServiceImpl({
    required Connectivity connectivity,
    required InternetConnection checker,
  })  : _connectivity = connectivity,
        _checker = checker;

  final Connectivity _connectivity;
  final InternetConnection _checker;

  @override
  Future<bool> get isConnected async {
    final List<ConnectivityResult> result =
        await _connectivity.checkConnectivity();

    final bool hasNetwork = result.contains(ConnectivityResult.wifi) ||
        result.contains(ConnectivityResult.mobile) ||
        result.contains(ConnectivityResult.vpn);
    if (!hasNetwork) {
      return false;
    }
    return _checker.hasInternetAccess;
  }
}

Relevant Log Output

Device/Network Information

Additional Context

No response

Would you like to work on this issue?

  • I'm interested in working on this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions