Step To Fix The 504 Error
Step 1: Root your phone from any custom recovery, i recommend you to install Phillz touch
(Root at your own risk)
Step 2: Download SuperSU root for rooting your device
Step 3: Install that SuperSu.zip from your custom recovery.
Step 4: After that install Xposed.zip file from recovery.
Now install any app from play store it will install without the 504
SuperSu and Xposed