[AT&T Samsung Galaxy S 4 Android Development] Tronicus:
Flash a Rom on an Encrypted Android

I spent an entire night trying to solve this problem properly. Actually it's quite quick, it's just that there is no documentation out there and I had to test a lot of options scrapped together from posts from all over the website. *sigh*.

How to Flash a rom on an encrypted Android phone (specifically this one, the I9505 SGH-I337).

The Problem: Once encrypted, you can't decrypt it easily. When encrypting the phone android will tell you you can only decrypt it using a factory reset. Naturally you assume it's talking about the "Factory Data Reset" option found in Settings --> Backup and Reset. But noooo, Android is lying through its ****ing teeth. Then you'll assume you have to wipe everything from your custom recovery mod (CWM, TWRP, or one of those). Wrong again! You'll get beautiful "can't mount /data" messages and more bull****. I read about a workaround that required installing the new rom using ADB, but I had ingeniously disabled USB debugging prior to wiping everything, so I only got so far with that option (plus it's tediously long if you haven't installed all the necessary software already and don't feel like bricking your phone because you made a typo in the command line). So, apparently the only other way to really format that partition free of its encryption is to use a stock recovery. So:

Short Version for Godlike users who know automatically how to do all this **** without any help (mimicking how most help posts are finely detailed on this site): Flash stock recovery, wipe everything, flash your custom recovery and install your new rom.

Long version for us mortals who don't know everything and haven't already downloaded already every single bit of software on earth:

Backup all the stuff you want to save. This process will truly wipe EVERYTHING. You can do it manually, or you can use an app like Titanium Backup Pro to help you (find it on Google Play Store). Here's a nice guide which recommends what to restore and what not to restore:

http://xdaforums.com/showthread.php?t=1480343

Flash the stock recovery using Odin. You can download a stock recovery from here:

http://xdaforums.com/showpost.php?p=49687791&postcount=3

It's the link called "I337MK2stockrecovery.tar.md5"

In case you don't know how to flash it with Odin, this short guide will help:

http://xdaforums.com/showthread.php?t=1506697

In step 6 replace "recovery.tar.md5" with the stock recovery you downloaded.

Wipe everything from the Stock recovery console. This little ****er will **** up the encryption all those sissies couldn't touch. You're welcome. You boot into recovery mode from a turned off phone by pressing simultaneously the volume up key + the home key + the power key until you see blue text appearing in the top left corner of your screen.

Reinstall your custom recovery. In my case I had installed the rom BEFORE flashing in the stock recovery (apparently it works, you just can't boot because of the encryption), so I was able to boot into the new rom before I returned to my custom recovery. Weird. Anyways, I recommend CWM. You can pick it up from this link:

http://goo.im/devs/philz_touch/CWM_Advanced_Edition/jflte

For some weird reason they call the I337 version the "jflte" version. It's bonkers. Click there, and download the latest version that ends with .tar.md5. This version is upgradable via Odin, which we already used. Use the same instructions used as when you upgraded the stock recovery rom.

Boot into your recovery mod and flash your rom like you usually do.

A word about TWRP: it cost me many hours of work and I don't recommend it. Its website is outdated, and recommends using GooManager (which is no longer mantained) and doesn't work anymore for this. GooManager suggests using a new, different app, which doesn't have the option of installing TWRP. Then I tried using their TWRP Manager app from play store and the image file wouldn't download. Then I tried manually selecting the image file in TWRP manager that I downloaded from their site for use via the ADB method, and it bricked my phone... twice (using two different methods the app sugested). I tried so much because in theory TWRP has the ability to decrypt android's 4.4 encryption, but after looking at their github site I noticed it was filled with people's reports (including people with the S4) on how it wouldn't work decrypting squat. So I gave up, and installed CWM in 30 seconds.