Parcelable, AIDL and IntelliJ

If you’re using IntelliJ IDEA to build your Android apps (as moi does), and you try to create AIDL files to sit beside your classes (specifically for the Parcelable interface), you may notice your own classes magically disappearing at compile time.

This stumped me for a while until I realised that normally an AIDL file would generate a .java file. It doesn’t for the Parcelable interface. But there’s a bug in IntelliJ which deletes your .java file on build. The way to get around this is to create a new source folder called aidl and add your AIDL file in with the same namespacing as where your main class lives. Then add the aidl folder to the module source folders (in module settings). Your aidl files will now be compiled into your project without nuking the existing .java files.

Update: Apparently, as of today, this bug has been fixed in IDEA X EAP. Still putting the post out there for people running on earlier versions.