Encryption Unsuccessful even after system backup restore The steps I performed:


Flashed TWRP with Odin
Made backup
Flashed LineageOS 14.1 with TWRP
Flashed SuperSU with TWRP
Flashed Open GApps with TWRP
There was a problem, Google Play Services kept crashing, I decided to restore stock ROM
Restored the backup I made in 2 with TWRP
Opened my restored system and decided to encrypt the device
Either the encryption failed itself or I somehow disturbed it
After restart Encryption Unsuccessful keeps appearing
I restored backup from 2 again I still get Encryption Unsuccessful
I flashed LineageOS again - started nicely
Once again I restored backup from 2 again I still get Encryption Unsuccessful


In the meantime I wiped Cache, Dalvik Cache, Data and System numerous times.

So it looks like the stock ROM keeps seeing the information about the failed encryption process even though I wiped the 4 partitions mentioned above. Interesting part is that LineageOS doesn't care.

Any ideas on how to get the stock ROM back on its feet?

EDIT

Flashing the stock rom with Odin didn't help either
Found out the way to fix it:


Download stock firmware (*.tar.md5)
Flash it with Odin (it removes TWRP and replaces it with a standard recovery)
Start Android - still "Unsuccessful encryption" error
Boot into recovery mode (now it's standard recovery instead of TWRP)
Run factory reset
Start Android - now it finally starts - problem solved
Flash again TWRP with Odin
Restore the old good backup with TWRP
Done


So basically the factory reset form the original recovery mode fixes it.

Also I found out why the tablet bricked. When it performs encryption process it looks like it's off (no lights, sounds or anything). Do not disturb it, after 20-30 minutes it finishes the encryption and turns itself on. Just leave it be until the screen turns on.