"adb devices" shows device as "unauthorized". How can I fix this?
You need to enable USB debugging on your phone. You should get prompted to accept an RSA key, which will mean that your computer is authorised.

Also keep in mind that any coding questions belong on StackOverflow.