androidthreetenbpthreetenabp

How to setup and use ThreeTenABP library


I can't get ThreeTenABP to work. Here's what I did:

  1. import dependency in app build.gradle

    implementation 'com.jakewharton.threetenabp:threetenabp:1.2.1'

  2. initialize the library in MyApplication.onCreate()

    AndroidThreeTen.init(this)

  3. add MyApplication to Manifest

    <application android:name=".MyApplication" ...>

  4. Use Instant to parse a String

    Instant.parse(updatedOn)

The only possible import for Instant is java.time.Instant. But this is not available until Android API 26, which is why I want to use ThreeTenABP in the first place. I found some examples using an import org.threeten.bp.Instant, but this import/package cannot be found in my case. I already did the infamous "Invalidate cache and restart", but to no avail. Is there anything else I am missing??


Solution

  • Okay sorry guys for waisting your time. I was adding the dependency in the wrong app-module. Now everything is working.