Since Android itself is an open-source operating system, running it on an emulator is legal and safe.