简体   繁体   中英

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??

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM