Skip to content
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

Fix IllegalStateException in getPurchaseHistory for Android #336

Closed

Conversation

mgonzalezc
Copy link
Contributor

The method getPurchaseHistory raises an IllegalStateException: Reply already submitted in Android
I am not sure if this is the best way to fix the issue because it makes the function slower, but at least the exception isn't thrown anymore

java.lang.IllegalStateException: Reply already submitted
at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:164)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:238)
at com.dooboolab.flutterinapppurchase.MethodResultWrapper$1.run(MethodResultWrapper.java:27)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7838)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

@codecov
Copy link

codecov bot commented Nov 29, 2021

Codecov Report

Merging #336 (7ecc5aa) into master (5988a56) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #336   +/-   ##
=======================================
  Coverage   45.97%   45.97%           
=======================================
  Files           3        3           
  Lines         435      435           
=======================================
  Hits          200      200           
  Misses        235      235           
Impacted Files Coverage Δ
lib/flutter_inapp_purchase.dart 54.43% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5988a56...7ecc5aa. Read the comment docs.

@4F2E4A2E
Copy link

4F2E4A2E commented Dec 1, 2021

I am getting this error as well. v5.1.2.
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale en-AT)

@4F2E4A2E
Copy link

4F2E4A2E commented Dec 1, 2021

@mgonzalezc thy very much for this pr, but I am still getting the same error with this commit.
I am trying you branch out by installing it via git:

flutter_inapp_purchase:
    git:
      url: git@github.com:mgonzalezc/flutter_inapp_purchase.git
      ref: fix/mindapps_fix

.pub-cache reveal the right dependency being loaded:

image

D/AndroidRuntime(21874): Shutting down VM
E/AndroidRuntime(21874): FATAL EXCEPTION: main
E/AndroidRuntime(21874): Process: ai.lobi.app, PID: 21874
E/AndroidRuntime(21874): java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(21874): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:164)
E/AndroidRuntime(21874): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:238)
E/AndroidRuntime(21874): 	at com.dooboolab.flutterinapppurchase.MethodResultWrapper$1.run(MethodResultWrapper.java:27)
E/AndroidRuntime(21874): 	at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(21874): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(21874): 	at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime(21874): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime(21874): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(21874): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime(21874): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@mgonzalezc
Copy link
Contributor Author

Hello!

Sorry about that! To be honest, this was a quick fix I made to have the plugin working with my own code. However, I think the issue is deeper and may need a bit more thinking. Now, I am thinking you could get the same error if you call getPurchaseHistory twice synchronously. There might be other cases when it fails as well

@dineshinworld
Copy link

When I delete handler, the package doesn't respond. The future is waiting and waiting and doesn't respond. This was the same problem I got in in_app_purchase.

@mgonzalezc
Copy link
Contributor Author

Sorry, @dineshinworld I was trying to test a few things and completely forgot that I had this PR opened in the same branch... I have reverted it now. It worked for me without the handlers though.

@github-actions
Copy link

This PR is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants