Greetings all,
I realize this issue has been posed before in other forms, and believe me, I have been searching the net for days trying to find the answer. However, I’m fairly new to Android and Java, and I need a little guidance please.
I presently have two version of my app, one for Android 1.5 and 1.6, and another for 2.0 and beyond. As you probably guessed, it’s because the Contacts API is different.
I recently became aware that it was possible to combine both methods into a single app, by using dynamically loadable classes. Very cool! After days of attempts, I still haven’t been able to do it successfully… or at least, it won’t run.
I have come across 3 examples of how to do this – one by Google, called “Business Card”, another that had something to do with Spinners, and a 3rd was something someone here created. My problem is that each one seems to me to have a showstopper.
I’m using Eclipse on Windows 7. My app was first created for A1.5, so that’s the one I’m upgrading. What’s happening is that my ContactsAccessorNewApi class needs to import the ContactContracts, and according to Eclipse, that won’t work because my project was originally built without support for it. Hence, it won’t run. I’ve tried adding the android.jar for SDK level 5 into the project, but that creates a whole mess of other problems.
My code for this pat of my app is exactly like the Google example “Business Card” – so if someone could help me cross this hurdle, I’d be very grateful. I’ll be happy to post any code that you need to answer my question.
Thank you!
If you mean this sample project, that’s mine.
You need to set your build target (Project Properties > Android) to be high enough that
ContactsContractexists (android-5or higher).So long as your
android:minSdkVersionin your manifest is set to support earlier versions of Android (e.g., 3 for Android 1.5), your app will still install on older emulator AVDs and devices.Yeah, don’t do that.