amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Network error only on Google Play internal test distribution

Open sk92129 opened this issue 6 months ago • 1 comments

Description

When I use the app on iOS -- downloaded thru TestFlight, there is no issue.

When I use the app on Android -- downloaded thru Internal Testing link on play store, it fails with "The request failed due to a network error".

When I sideload the app on Android, the code works without issues. When I debug the code on the android emulator or real device, there is no issues.

  try {
    final SignInResult result = await Amplify.Auth.signIn(
      username: username,
      password: password,
    );
  } on AuthException catch (e) {
    debugPrint('Error during sign-in: ${e.message}');
    var nextStep = e.message;
    var strExceptionClassName = e.runtimeType.toString();
    SignedModel model = SignedModel(
      signedIn: false,
      userId: username,
      nextStep: "$nextStep :  $strExceptionClassName",
    );
    return model; // return some error msg
  }

Anybody experienced this?

The object that I return encapsulates the result from Amplify and it is basically a NetworkException: The request failed due to a network error.

I think I am using Gen1

Categories

  • [ ] Analytics
  • [ ] API (REST)
  • [ ] API (GraphQL)
  • [x] Auth
  • [ ] Authenticator
  • [ ] DataStore
  • [ ] Notifications (Push)
  • [ ] Storage

Steps to Reproduce

  1. Install my app thru the google internal testing link distribution.
  2. Launch my app
  3. I click Signin UI which prompts for email/password
  4. Submit
  5. Then the snack message appears "The request failed due to a network error : Network Exception"

Screenshots

No response

Platforms

  • [ ] iOS
  • [x] Android
  • [ ] Web
  • [ ] macOS
  • [ ] Windows
  • [ ] Linux

Flutter Version

3.32.4

Amplify Flutter Version

2.6.2

Deployment Method

Amplify CLI (Gen 1)

Schema

I think I am using Gen1.

sk92129 avatar Jun 20 '25 06:06 sk92129

Hi @sk92129, thank you for raising this issue. We will investigate and see if there is a remedy to this

ekjotmultani avatar Jun 21 '25 17:06 ekjotmultani

@sk92129, just to confirm, have you set network permissions for Android release builds?

ekjotmultani avatar Jun 23 '25 21:06 ekjotmultani

That solved it. Very odd that that another http operation works without that permission.

I have something like this:

    try {
      final response = await http.get(Uri.parse('$_baseUrl/books'));
      
      if (response.statusCode == 200) {
        final List<dynamic> jsonList = json.decode(response.body);
        return jsonList.map((json) => Books.fromJson(json)).toList();
      } else {
        print(response);
        throw Exception('Failed to load books');
      }
    } catch (e) {
      throw Exception('Failed to connect to the server: $e');
    }

sk92129 avatar Jun 23 '25 22:06 sk92129

Hello @sk92129, I'm glad we could resolve the issue!

Both the Flutter and Android networking documentation indicate that this permission is required to access the internet, so I'm surprised any http operations would succeed. If you are using a local caching mechanism it could persist from a development build of your app

tyllark avatar Jun 23 '25 23:06 tyllark

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] avatar Jun 28 '25 00:06 github-actions[bot]