How can I fix the "incompatible data" issue when flashing Cyanogenmod onto my Xperia Z3 Compact? I have a Sony Xperia Z3 Compact and I am trying to install Cyanogenmod 12.1.

I followed the guide on the Cyanogenmod Wiki for my device.

The process went smoothly initially but it fails at 40-50% completion with the message: "Install failed. Can't install this package on top of incompatible data.....E:Failed to install /sideload/package.zip..."

I've tried:


Performing a factory reset
Flashing an older version of Cyanogenmod


But I receive the same message when I try to flash.

When I restart the phone, it hangs indefinitely on the Sony loading screen and doesn't boot.

How can I resolve this issue and successfully flash Cyanogenmod?

EDIT:

I installed TWRP 3.0.2.1 and it start to reboot the phone in loop, but I manage to install 3.0.2.0 version. I was trying this time to install from usb memory, but it faild to error 7: 
https://drive.google.com/open?id=0Bx_77SKdWXozZ1NVUDIwOEFSZGM 

I manage to get terminal open and I found out that I have linux version 3.4.0-cm-g28a6663
Usually just wiping /data from the recovery and/or installing the package again immediately after first failure should get you through.

However if it doesn't, then you might want to ditch Cyanogen Recovery (that comes with the boot.img you flashed) and use TWRP. Find some here at XDA-Developers - basically any one that integrates TWRP should work, because you will be substituting it with CM's boot.img later when flashing, but it's advised that you choose one that's built for the same Android version you were on before flashing.

This sounds a bit hard to swallow and it is, but it's essential flashing skills and you will need it. With TWRP you can also put the package in internal storage and flash it from there, instead of relying on your PC to do a sideload.