I've just recently installed Ubuntu 17.04. Also, I installed Android Studio in the default desktop and it works fine, but when I switch to Unity 8 and then try to launch Android Studio I get this message:
$ cd /usr/local/android-studio/bin/
$ ./studio.sh
Startup Error: Unable to detect graphics environment