So the new SDK 5 release presented a new ContactsContract library that I want to use. I also want to keep my app compatible with SDK 4. I am having trouble accomplishing both. The problem is that even if the code path does not get to SDK-5-only code in an SDK 4 run, the class that uses the SDK-5-only code crashes immediately before it gets to onCreate when running on SDK 4, because Java is unable to compile the code for the newer SDK (that one actually took me awhile to realize). So, I started thinking about conditional compilation, and I found this nice workaround:
However, it doesn't seem to be working for me. Here is what I am trying:
According to the link above, the compiler should just completely ignore the SDK 5 stuff if IS_SDK_5_COMPATIBLE is false. Now for the weirdest part. If I do this:
then everything works just fine in SDK 4. I'm guessing there is something going on here that is way over my head, so if anyone can make sense of any of this, please tell me what's happening and how I can properly make my code backwards compatible.