Tiago A. Tiago A. - 1 month ago 7
Android Question

Android: Getting a NoClassDefFoundError in my own class

I am developing an Android project that was working fine. After updating to OSX Mavericks, when I opened Android Studio, it showed a message saying that it needed to update JDK. I did so and everything went fine. I can compile the app, but it throws a

NoClassDefFoundError
in one of my own classes.

10-25 10:24:10.403 12318-12318/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.vitasalutis.client.main.parameterwidgets.graphs.ParameterWidgetGraphicalView
at com.vitasalutis.client.main.parameterwidgets.MainWidget.<init>(MainWidget.java:215)
at com.vitasalutis.client.main.ParameterMenuFragment.onCreateView(ParameterMenuFragment.java:107)
at android.app.Fragment.performCreateView(Fragment.java:1695)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:861)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1137)


The
ParameterWidgetGraphicalView
belongs to the same module and project as the activity, so it's not a linking problem.

I am compiling and testing with API-17.

What I have tried:


  • Downloaded JDK7, and used that on the project.

  • Reinstalled Android Studio completely from scratch (deleted all user files).

  • Created project from scratch and copy-pasted the previous source.

  • Compiled and tested another similar project (not gradle, though) in Android Studio. It worked fine.

  • Went back to my Win8 machine. The app works fine...



Other questions on the net suggest that it may be a SDK/JDK version problem. That doesn't explain why I am able to compile/run other projects.

Thanks!
I miss my Mac...

[UPDATE] Solved!

The problem was not that it couldn't find the ParameterWidgetGraphicalView class, but its parent that was compiled in a jar.

I re-compiled that jar, and now it works.

Answer

Solved it.

The problem was not that it couldn't find the ParameterWidgetGraphicalView class, but its parent.

The parent was compiled in a jar. I don't know why it didn't work, but I re-compiled that jar, and now it works.

Probably something to do with JDK versions...

Comments