Android ical4j NoSuchMethodError error at java.time.zone.ZoneRulesProvider

27 Views Asked by At

The current issue is arising in an Android project when using the iCal4j library, due to a conflict between Java 8's java.time package and the java.time package in the Android SDK. The iCal4j library internally uses Java 8's java.time package, leading to a collision. This results in a java.lang.NoSuchMethodError during runtime.

when I run this code

vtimeZone = timeZoneRegistry?.getTimeZone(tzId)?.vTimeZone

DefaultContentHandler class use java.time.zone.ZoneRuleProvider but sdk lib does not have ZoneRulesProvider. so java.lang.NoSuchMethodError is occur

How can i resolve this error? Here is my lib version

  library("calendar-ical4j", "org.mnode.ical4j:ical4j:4.0.0-rc1")
  library("calendar-ical4jExt", "org.mnode.ical4j:ical4j-extensions:2.0.0-rc1")
  library("calendar-threetenabp","com.jakewharton.threetenabp:threetenabp:1.3.1")

I tried using threetenabp lib and init in Application class at onCreate function.

Here is my code

super.onCreate()
AndroidThreeTen.init(this)
ZoneRulesProvider.registerProvider(DefaultZoneRulesProvider() as ZoneRulesProvider)

and

super.onCreate()
AndroidThreeTen.init(this)
ZoneRulesProvider.registerProvider(TzdbZoneRulesProvider())

The first approach did not have any effect(NoSuchMethodError occur), and the second approach resulted in an error. org.threeten.bp.zone.ZoneRulesException: No time-zone rules found for 'TZDB'

0

There are 0 best solutions below