I am trying to build ICS contacts code on eclipse. As contacts was using some hidden classes, I created a new jar file with all the required classes and was successful in building the apk.
But now the problem is the classes whichever I added in the jar are missing links in the final apk package and I am getting noClassDefFoundError exception.
I decompiled the apk and found that class was present in the apk. Why the link is missing eventhough class file is present in the apk?
I tried using the jar file as an external library but because of its size (>20mb) was not successful.
The Contacts app is using several types of hidden files. Some of them are hidden framework items, like AggregationSuggestions.PARAMETER_MATCH_NAME, and others belongs to the static libraries like com.android.phone.CallLogAsync. First kind of files should never be embedded into your APK, but the second should be.
If you look into Android.mk for the Contacts you can figure out what static libraries are needed:
LOCAL_STATIC_JAVA_LIBRARIES := \ com.android.phone.common \ com.android.vcard \ android-common \ guava \ android-support-v13 \ android-support-v4 \ android-ex-variablespeed \
To compile Contact in eclipse you should add framework classes as "User library" and all static libraries as "External JAR".
The easiest way to obtain all needed jars is to build Android sources and look into out/target/common/obj/JAVA_LIBRARIES. Each library has its own directory named libname_intermediates with classes-full-debug.jar in it. These jars are exactly what you need to build Contacts. Framework classes reside in framework_intermediates, however you may need to add some more jars.
You should adjust "Order & Export" for your project in Eclipse to make sure that your "User Library" with framework classes is above of "Android 4.0".