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
Fatal Exception: java.lang.IllegalStateException: Reply already submitted #339
Comments
Hello! yes, it is I have ended up using version 5.0.4. The crash isn't there for this version I think the issue is related to the new handlers in MethodResultWrapper.java, added in #328. From what I could investigate, when getPurchaseHistory is called, the channel receives result.success twice. This is not allowed and that's why "Reply already submitted" fires. My PR #336 helps a bit because it makes the calls under getPurchaseHistory asynchronous but if you call it several times in your code (for example, with a retry strategy when there is no connection) then the exception is fired as well. |
Hello @mgonzalezc |
Ok the problem still exists. I have downgraded to version 5.0.4 |
me too downgraded back to |
I've updated firebase to the latest version, and same error is occurring on flutter_inapp_purchase: ^5.0.2
It seems that I've found a problem. What i did to fix that was to change the
to
in the Back to drinking. Bye. |
Same here. |
@jesselpereira I have the same problem :( Did you solve it ?? |
Hi dude, I just abandoned that package, migrated to in_app_purchase and solved my problems. |
@jesselpereira okay, thank you for answer :) So in that package it will automatically detect call update purchase callback on app open?)) |
I believe it is worth trying to do this. In my project I have a callback when a purchase is completed, but I don't check it when I open the app. But this is an option that fits my project, nothing prevents you from implementing the package in your project. I believe this package here has been deprecated, or it's not a recognized flaw. |
Hello, I got the error on v5.0.4, v5.1.0, v5.1.1 and v5.1.2. |
Hi, |
Worked like a charm :) |
Hello Guys. Use my library with fix https://github.com/valterh4ck3r/flutter_inapp_purchase My fix: #356 Use this dependency on pubspec.yaml
|
Pls pull request your changes. 👏🏻 |
Created Pull Request |
This didn't work for me. still facing when I call FlutterInappPurchase.instance.getAvailablePurchases() in android |
@valterh4ck3r |
This error happens when flutter calls 2 functions at the same time. The method call cannot respond at the same time with success or error results, so I've re-implemented the service to not make 2 calls at the same time. Anyone with the same fix? |
You have it. Please change the part then it will work Future<List<PurchasedItem>?> getPurchaseHistory() async {
if (_platform.isAndroid) {
final inappPurchaseHistory = await _channel.invokeMethod(
'getPurchaseHistoryByType',
<String, dynamic>{
'type': describeEnum(_TypeInApp.inapp),
},
);
final subsPurchaseHistory = await _channel.invokeMethod(
'getPurchaseHistoryByType',
<String, dynamic>{
'type': describeEnum(_TypeInApp.subs),
},
);
return extractPurchased(inappPurchaseHistory)! + extractPurchased(subsPurchaseHistory)!;
} else if (_platform.isIOS) {
dynamic result = await _channel.invokeMethod('getAvailableItems');
return extractPurchased(json.encode(result));
}
throw PlatformException(
code: _platform.operatingSystem, message: "platform not supported");
} |
Wait for 1 second, before call method channel again. Future<List<PurchasedItem>?> getPurchaseHistory() async {
if (_platform.isAndroid) {
final inappPurchaseHistory = await _channel.invokeMethod(
'getPurchaseHistoryByType',
<String, dynamic>{
'type': describeEnum(_TypeInApp.inapp),
},
);
await Future.delayed(Duration(seconds: 1) , (){});
final subsPurchaseHistory = await _channel.invokeMethod(
'getPurchaseHistoryByType',
<String, dynamic>{
'type': describeEnum(_TypeInApp.subs),
},
);
return extractPurchased(inappPurchaseHistory)! + extractPurchased(subsPurchaseHistory)!;
} else if (_platform.isIOS) {
dynamic result = await _channel.invokeMethod('getAvailableItems');
return extractPurchased(json.encode(result));
}
throw PlatformException(
code: _platform.operatingSystem, message: "platform not supported");
} |
The main problem is this line of code List<dynamic> results = await Future.wait([getInappPurchaseHistory, getSubsPurchaseHistory]); because the calls are sent in parallel and not in a queue. The timeout of one second is not needed in my test environment. But your fix in Java Source seems to need it too. Can you make a new pull request with my fix which I posted above? |
Yeah, it's perfect. I will make new pull request, thank you so much @offline-first |
Done. |
@valterh4ck3r @offline-first Any updates on this? I am still facing the same error on version 5.1.2. |
@valterh4ck3r please use my fix for the async issue! |
@offline-first can you send PR with your fix to repo ? I can merge into my repo too. |
@valterh4ck3r done |
Thank you so much |
@offline-first merged. |
@valterh4ck3r @offline-first Sorry if I am getting it wrong. But why was the PR #359 closed since it has already been approved to be merged by @hyochan. Thank you guys for the collaboration on the package. |
I think @valterh4ck3r has trouble managing the branch. I'll open up the |
Closes due to #360 Released in |
Thanks @hyochan, purchase history is now works correctly again on android |
I got the error from Firebase Crashlytics. Are there any insights into this? Is this related to #336 @mgonzalezc ?
Crash on: Android 9, Galaxy Note9 (real device)
The text was updated successfully, but these errors were encountered: