Add code to handle exceptionanl environments in XML

see http://www.slideshare.net/yusukey/android-6595931/10