Raneez Ahmed
Raneez Ahmed

Reputation: 3828

How to fix NoClassDefFoundError occured while using a third party library in our application?

I am using android wheel to select date and time in my application. but i am fed up with this NoClassDefFoundError while using this library.

I included wheel.jar in the libs folder, but still i get error at runtime.

Here is the logcat error:

08-08 15:19:22.078: E/AndroidRuntime(21223): FATAL EXCEPTION: main 08-08 15:19:22.078: E/AndroidRuntime(21223): java.lang.NoClassDefFoundError: kankan.wheel.R$drawable 08-08 15:19:22.078: E/AndroidRuntime(21223): at kankan.wheel.widget.WheelView.initResourcesIfNecessary(WheelView.java:427) 08-08 15:19:22.078: E/AndroidRuntime(21223): at kankan.wheel.widget.WheelView.calculateLayoutWidth(WheelView.java:482) 08-08 15:19:22.078: E/AndroidRuntime(21223): at kankan.wheel.widget.WheelView.onMeasure(WheelView.java:518) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.View.measure(View.java:12775) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1385) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1027) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.LinearLayout.onMeasure(LinearLayout.java:565) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.View.measure(View.java:12775) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.View.measure(View.java:12775) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.View.measure(View.java:12775) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.View.measure(View.java:12775) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.View.measure(View.java:12775) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) 08-08 15:19:22.078: E/AndroidRuntime(21223): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2240) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.View.measure(View.java:12775) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1151) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2539) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.os.Handler.dispatchMessage(Handler.java:99) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.os.Looper.loop(Looper.java:137) 08-08 15:19:22.078: E/AndroidRuntime(21223): at android.app.ActivityThread.main(ActivityThread.java:4514) 08-08 15:19:22.078: E/AndroidRuntime(21223): at java.lang.reflect.Method.invokeNative(Native Method) 08-08 15:19:22.078: E/AndroidRuntime(21223): at java.lang.reflect.Method.invoke(Method.java:511) 08-08 15:19:22.078: E/AndroidRuntime(21223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 08-08 15:19:22.078: E/AndroidRuntime(21223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 08-08 15:19:22.078: E/AndroidRuntime(21223): at dalvik.system.NativeStart.main(Native Method) 08-08 15:24:27.601: I/Process(21223): Sending signal. PID: 21223 SIG: 9

Upvotes: 0

Views: 2317

Answers (3)

Raneez Ahmed
Raneez Ahmed

Reputation: 3828

Atlast i found the solution,

Instead of adding the jar file in the build path, go to project properties -> Android -> click add in the library section -> and select the library project.

enter image description here

enter image description here

Upvotes: 2

Midhu
Midhu

Reputation: 1697

Try Ordering and exporting your jar libraries within the project.

Follow the steps below(in Eclipse):

  1. Go to project properties
  2. Select Java Build Path
  3. Select last tab "Order and Export"
  4. Move Your Jar(Library) to the top position
  5. Clean And Build Project

I don't know what is exactly happening, but once i had the same issue and I solved it in the above manner. Hope this will be a help to you too.

Upvotes: 2

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

You should try this:

  1. Remove all references to the JAR in your project from Java Build Path.-> your code should not build without error anymore

  2. Create a libs folder if not exist at the root of your project Copy the JAR into the libs folder.

  3. If still not running OK. Right click your project > Android Tools > Fix Project Properties

clean your project and run. it will work

look at this existing answ Getting NoClassDefFoundError

Upvotes: 2

Related Questions