Sunday, January 6, 2013

Tips to add Support Library

In case you need to add Android Support Library, such as android-support-v4.jar; Google documents suggested to:
- In Eclipse Select Project > Properties, select Java Build Path, and navigate to Libraries.
- Select Add External Jars, include the following jar files, and click OK: <android-sdk-folder>/extras/android/compatibility/v4/android-support-v4.jar

But...I found that it is not always work, even always NOT work!

No error when you compile your code, but fail with error "Caused by: java.lang.NoClassDefFoundError: youractivity" at runtime.

My alternatively, Right click your project, select Android Tools > Add Support Library...

Add Support Library...


----------

Here is another solution advised by Stefan de Bruijn in comments:
- create a folder called "libs", NOT "lib".
- copy the required jar in "libs" folder.
- Update Java Build Path by selecting "Add JARs..." (NOT "Add External JARs...") to add the jar in libs.
- like this: java.lang.NoClassDefFoundError: com.google.ads.AdView.

4 comments:

Unknown said...

Actually all you need to do is create (if it isn't there yet) a folder called 'libs' (exactly, nothing else!) and place any .jar you want in there and the rest is all automagic ;)

Erik said...

Hello Stefan de Bruijn,

Yes, "Add JARs..." instead of "Add External JARs..." is another alternative.

I have updated the post with your advise.

Thx:)

Anonymous said...

Hi

As per your reply regarding Tips to add Support Library, I tried to do it in my application. But its not working.

Can you please forward me more solution to display google map in my android emulator?

Its really urgent. Please help me.

Reply me on my following id: sneha2011.jobs@gmail.com

Erik said...

please notice that Google Play services (include Maps API V2) is not supported on the Android emulator.