question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IllegalStateException instantiating DropInClient in started activity

See original GitHub issue

General information

  • SDK/Library version: 6.1.0
  • Environment: sandbox
  • Android Version and Device: any

Issue description

I’m trying to upgrade to version 6.1.0 where the constructor DropInClient(Context, String, DropInRequest) is deprecated. However, new constructors throw

java.lang.IllegalStateException: LifecycleOwner [omissis].MainActivity@4e33d58 is attempting to register while current state is RESUMED. LifecycleOwners must call register before they are STARTED.
        at androidx.activity.result.ActivityResultRegistry.register(ActivityResultRegistry.java:123)
        at com.braintreepayments.api.DropInLifecycleObserver.onCreate(DropInLifecycleObserver.java:30)
        at androidx.lifecycle.FullLifecycleObserverAdapter.onStateChanged(FullLifecycleObserverAdapter.java:36)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
        at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
        at com.braintreepayments.api.DropInClient.addObserver(DropInClient.java:175)
        at com.braintreepayments.api.DropInClient.<init>(DropInClient.java:169)
        at com.braintreepayments.api.DropInClient.<init>(DropInClient.java:126)
       [...]

when the referenced FragmentActivity is already started, which wasn’t the case with the deprecated constructor. I can’t instantiate the client before in the activity, since I don’t have all the details from the user to construct the DropInRequest, unless I launch a dedicated one (which I’d prefer not to). Is this the intended behaviour?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sshropshirecommented, Aug 29, 2022

Hi @mtrakal we do have a pull request #358 up to make this change. We’re doing our due diligence to get it merged in. We don’t have an expected timeline on completion, but I’d expect it to be available in the next release.

Also feel free to review the PR!

0reactions
mtrakalcommented, Aug 29, 2022

Hi, is there any progress in move DropInRequest to start() or launchDropIn() method?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems with initializing ThreeDSecureClient #541 - GitHub
You must instantiate the DropInClient in onCreate to allow your application to recover in case a process kill has occurred, and your Activity/ ......
Read more >
java.lang.RuntimeException: Unable to instantiate activity ...
RuntimeException: Unable to instantiate activity ComponentInfo exception and that is the activity that you are trying to start is abstract.
Read more >
Braintree Drop-In SDK for Android - AndroidRepo
To launch Drop-in, instantiate a DropInClient with client ... IllegalStateException: Fragment must be attached to an activity. at ...
Read more >
Braintree Drop-In SDK for Android - AndroidRepo
To launch Drop-in, instantiate a DropInClient with client authorization and call ... IllegalStateException: Fragment must be attached to an activity. at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found