The problem was, I was performing all the main functionality on the main GUI thread.
I did multi-threading, now it works.
Also one of the reasons it crashed on the AVD was the memory on it was small, before multi-threading, on an actual device it had no issues.