How to solve java.lang.NoClassDefFoundError?

前端 未结 27 1511
暗喜
暗喜 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);
      }
    

提交回复
热议问题