I too had this problem, and searched lot of things in Internet, but I solved by a simple step
I don't know the exact Cause, But I solved it by Restarting Emulator or create a NEW Emulator, and Run the project in that new Emulator
I won't say this is the exact answer but Try it before modifying your coding with Complex codes