Android Apk Security. How to make the game can't be run if it's not downloaded from google play?

I have Made an Action, Adventure, open world. Game called “LAUC”.
I Wanted To Publish it to play store and appstore.
But. How to make the game run only if it downloaded from play store ?. I mean. If someone purchased the game and published it for free. It won’t run. Like Spiderman 2 apk.
Do you have any idea about that ?. Like additional files to protect the game from illegal sharing ?.

I’ve did it by myself.