Search code examples
javaandroidandroid-mediaplayer

NoClassDefFoundError in onStart method - Android


I am implementing Amazon IAP into my Media player app. I have registered my observer as it was said in Amazon docs. But, when I ran the project it is throwing NoClassDefFoundError.

There is no compilation error in the project and the class is right there in the project with correct package name. Searched other forums but not able to solve the issue.

Any help is greatly appreciated!!

11-08 21:02:07.399: E/AndroidRuntime(11667): FATAL EXCEPTION: main
11-08 21:02:07.399: E/AndroidRuntime(11667): java.lang.NoClassDefFoundError: com.songs.mysongs.PlaySongObserver
11-08 21:02:07.399: E/AndroidRuntime(11667):    at com.songs.mysongs.PlaySongActivity.onStart(PlaySongActivity.java:111)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.app.Activity.performStart(Activity.java:4639)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1972)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2024)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.app.ActivityThread.access$600(ActivityThread.java:126)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.os.Looper.loop(Looper.java:137)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at android.app.ActivityThread.main(ActivityThread.java:4479)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at java.lang.reflect.Method.invokeNative(Native Method)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at java.lang.reflect.Method.invoke(Method.java:511)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-08 21:02:07.399: E/AndroidRuntime(11667):    at dalvik.system.NativeStart.main(Native Method)

Solution

  • Try this.If you are using new SDK there is quite different way of adding library in the project.

    1. Create folder named as libs in your project and place your library over there.
    2. Right click on your project > Build Path > Add External Archives

    I hope this will resolve your issue.If you have already added the library by using add external library then try to follow the steps which I mention.