简体   繁体   中英

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)

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.

NoClassDefFoundError because of following:

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

In your case com.songs.mysongs.PlaySongObserver class are not found by JVM. So you have to check might be your class path is not properly set Or if you are using IDE (like Eclipse) then check is that class is selected for run time.

添加jar之后,检查它是否要导出到。

Cleaning the project has resolved NoClassDefFoundError with the purchasing observer in my case; I guess .jar libraries are not always picked up automatically?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM