Friday, 21 February 2014

Copying a template project

Today I fell upon a problem that really baffled me for a while.  Android Studio just refused to create my R class.  No lint problems, no compile problems (besides the missing R), nothing.  It just failed. I searched on the net but problems like that are difficult to find answers to because Android Studio is in such fluctuation that the answers no longer apply.

I tried cleaning my project. Rebuilding my project. It was then suggested that I invalidate my caches and restart Android Studio (you can find that in the File menu) but that didn't work.  I deleted my build directory. Nothing would work. Then it dawned on me...

I was trying to create a project from a template project that I created.  The Coloroos project will have many coloring books and each will require it's own project, so I wanted to create a template project and just copy paste it and go. What I did was copy and paste the project and then open it in Android Studio. There lies the problem. In order to properly reset everything I need to delete the .idea directory from the pasted project and then import it into Android Studio. Once I did that, it compiled and ran immediately.