Search code examples
androidproguardandroid-multidex

Fatal Exception: java.lang.NoClassDefFoundError Failed resolution of: Ljava/time/Month in some devices


I get this crash with the following stack trace:

Caused by java.lang.ClassNotFoundException
Didn't find class "java.time.Month" on path: DexPathList[[zip file "/data/app/com.my.app/base.apk"],nativeLibraryDirectories=[/data/app/com.my.app/lib/arm, /data/app/com.my.app/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass + 56(BaseDexClassLoader.java:56)
   at java.lang.ClassLoader.loadClass + 380(ClassLoader.java:380)
   at java.lang.ClassLoader.loadClass + 312(ClassLoader.java:312)
   at com.my.app.root.path.to.my.Class$disableDays$1.onMonthChanged + 37(Class.java:37)
   at com.applikeysolutions.cosmocalendar.view.CalendarView.containsFlag(CalendarView.java:77)
   at com.applikeysolutions.cosmocalendar.view.CalendarView.onSnap + 1073(CalendarView.java:1073)
   at com.applikeysolutions.cosmocalendar.utils.snap.GravityDelegate$1.onScrollStateChanged + 33(GravityDelegate.java:33)
   at androidx.recyclerview.widget.RecyclerView.dispatchOnScrollStateChanged + 4998(RecyclerView.java:4998)
   at androidx.recyclerview.widget.RecyclerView.setScrollState + 1545(RecyclerView.java:1545)
   at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run + 5134(RecyclerView.java:5134)
   at android.view.Choreographer$CallbackRecord.run + 910(Choreographer.java:910)

I've considered that my app may not have been multi-dexed but it is already multi-dexed in my Manifest (java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/LocalDate; error); and even multi-dexing my app programmatically still makes this issue regress in some devices.

Is there any reason to suspect that I have a problem with the relationship between com.applikeysolutions.cosmocalendar.view.CalendarView(https://github.com/ApplikeySolutions/CosmoCalendar) and my Proguard, please? The said library has no entry in my Proguard rules as of yet.

Thank you!


Solution

  • the java.time package was added only in API 26.

    https://developer.android.com/reference/java/time/package-summary

    And for prior versions, you can use org.joda.time.LocalDate