I'm was testing ClipboardManager
to copy a String to the device's clipboard when clicking a button. I started spam clicking the button to test it and it ended up crashing my emulator.
//In my activity
@OnClick(R.id.btn_copy_address)
void onCopyAddressClick() {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Text label", "123 Sesame Street");
clipboard.setPrimaryClip(clip);
}

The error being thrown in logs:

Second attempt: This was caused by having a Toast
after the ClipboardCopy. No longer threw this error once I removed the Toast
```
java.lang.RuntimeException: Adding window failed
at android.view.ViewRootImpl.setView(ViewRootImpl.java:738)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.widget.Toast$TN.handleShow(Toast.java:496)
at android.widget.Toast$TN$1.handleMessage(Toast.java:400)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:764)
at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:791)
at android.view.ViewRootImpl.setView(ViewRootImpl.java:726)
```
Third attempt:

The fourth attempt returns the same error log as the third.
Does anyone know what the cause of the crash is? Or how I can fix it?