How to solve java.lang.NoClassDefFoundError?

前端 未结 27 1491
暗喜
暗喜 2020-11-21 06:04

I\'ve tried both the example in Oracle\'s Java Tutorials. They both compile fine, but at run-time, both come up with this error:

Exception in thread \"main\"         


        
相关标签:
27条回答
  • 2020-11-21 06:47

    I have faced with the problem today. I have an Android project and after enabling multidex the project wouldn't start anymore.

    The reason was that I had forgotten to call the specific multidex method that should be added to the Application class and invoked before everything else.

     MultiDex.install(this);
    

    Follow this tutorial to enable multidex correctly. https://developer.android.com/studio/build/multidex.html

    You should add these lines to your Application class

     @Override
      protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
         MultiDex.install(this);
      }
    
    0 讨论(0)
  • 2020-11-21 06:51
    java.lang.NoClassDefFoundError
    

    indicates, that something was found at compiletime but not at runtime. maybe you just have to add it to the classpath.

    0 讨论(0)
  • 2020-11-21 06:51

    I got this error after a Git branch change. For the specific case of Eclipse,there were missed lines on .settings directory for org.eclipse.wst.common.component file. As you can see below

    Restoring the project dependencies with Maven Install would help.

    0 讨论(0)
提交回复
热议问题