Android - How do I setup a Gmail account with 2-step verification in K-9 Mail?

IMAP clients generally need to use application-specific passwords in order to access accounts that use 2-step verification. You'll need to generate a new app-specific password, then use that to set up your incoming/outgoing servers instead of using your regular account password. Google's support page (linked above) includes instructions for doing this. Summarized, the procedure is:

How to generate an application-specific password

  1. Visit your Google Account settings page.
  2. On the left, click Security.
  3. Under the "Signing in to Google" topic, click App Passwords.
  4. Using the dropdown menus within under the App Passwords section, select which application you would like to generate a password for along with the device then click "GENERATE". You'll then see the application-specific password (ASP) you just created along with instructions on how to use it.
  5. When you sign in to an application requiring an ASP, enter your ASP in the password field, and make sure you check the "Remember password" option if you want the application to remember the code.