This video demonstrates how to reproduce the current bug in SharePoint 2013 which destroys your apps when changing the master page.
Pre-requisites: Publishing Infrastructure enabled on the Site Collection, Publishing enabled on the site hosting the app.
1) add App
2) change masterpage of site using the app
3) make sure tou tick the reset all sub sites option
4) try to administer the app..Oops.
When an app is added to your site, a separate subsite is created to host the app. Although this subsite is hosted in a completely different URL, it is still treated as a subsite of your main intranet. So when you go ticking the reset all sub sites box, all existing apps will lose their default masterpage and will receive a reference to the new masterpage. This obviously can’t happen, as that would mean the app could access resources outside of its allowed list and that’s why SharePoint throws the error at you.