Random java.lang.NoClassDefFoundError on Android

I am using a crash reporting tool that puts traces when an exception is thrown. I see them from time to time java.lang.NoClassDefFoundError

, and I usually never pay attention to them because it is only 1 failure for every 10,000 sessions or more. Strange thing:

  • Usually for different classes (i.e. NoClassDefFoundError

    for class MyAwesomeClass

    and MyOtherAwesomeClass

    ) it rarely happens twice for the same class.
  • The crash usually only happens once to one user (i.e. no user has more than one NoClassDefFoundError

    for the same class).
  • I have never been able to reproduce the error.

Now my question is, could this be a "device-specific problem", that is, something that the Android X manufacturer might have done wrong? Could this be an OS issue?

Has anyone had a similar problem? Any theories on why this might be happening?

+3


source to share


1 answer


I also came across NoClassDefFoundError

in my projects. This error was thrown when I was running my app on a lower Android version like 2.2 and my app uses apis

that were not available for a lower Android version, for example if I try to run my code with a Fragments

lower version from android or of my class declare some event listener or code related to NFC etc. that is not available in this version of Android on which I am running my app.



So, to avoid this error, you can use Android version check in your code in places where you are using apis that are not available in lower Android version.

0


source







All Articles