Home » Java » java.lang.NoClassDefFoundError exception on some devices

java.lang.NoClassDefFoundError exception on some devices

Posted by: admin December 28, 2021 Leave a comment


I have an ImageView in my Fragment, on which am setting an onClick Listener.

This is running fine on Nexus, oneplus but I get the following error on some devices.

The $1 signifies an Inner class, which is the onclicklistener. If I comment out the onclicklistener code, the Activity and the Fragment launch fine. Why is this? What is the issue?


It seems that your app reach the limitation of 65K methods, which is quite famous limitation of Android.

Ref: https://developer.android.com/tools/building/multidex.html#dev-build

You can follow the solution in above link. Or in short:

If you have your Application class (you extends class Application), override attachBaseContext() in that class and call Multidex.install(this)

otherwise add this to your Manifest:


inside <application> tag.

Please reply here if it solves your problem. It solves mine actually.


I had this issue running a Samsung Android 8.0 device, however no issue on Samsung Android 9. Enabling multidex and extending multidex application didn’t help.

The only thing that fixed it was reducing the gradle tools version from 3.5.1 to 3.4.1 (com.android.tools.build:gradle:3.4.1)