Network error only on Google Play internal test distribution
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
- Install my app thru the google internal testing link distribution.
- Launch my app
- I click Signin UI which prompts for email/password
- Submit
- 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.
Hi @sk92129, thank you for raising this issue. We will investigate and see if there is a remedy to this
@sk92129, just to confirm, have you set network permissions for Android release builds?
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');
}
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
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.