Search code examples
androidgradlesonatypethreetenbp

Unable to compile ThreeTenABP


I am trying to use Jake Wharton's ThreeTenABP library - https://github.com/JakeWharton/ThreeTenABP - for JSR310 date/time features in my Android project. This library's main advantage is that it has less compile overhead than Jodatime (http://www.joda.org/joda-time/) and threetenbp (https://github.com/ThreeTen/threetenbp). However, the ThreeTenABP library isn't compiling in my project. I am putting the following in my build.gradle:

compile 'org.threeten:threetenbp:1.3-SNAPSHOT'
compile 'com.jakewharton.threetenabp:threetenabp:1.0.0-SNAPSHOT'

And I get a compilation error:

Error:Could not find org.threeten:threetenbp:1.3-SNAPSHOT. Required by: MyApp:app:unspecified MyApp:app:unspecified > com.jakewharton.threetenabp:threetenabp:1.0.0-SNAPSHOT Search in build.gradle files

Has anybody used this library successfully in Android before?


Solution

  • This is a problem with the build process, not being able to download the dependency.

    This is most likely caused, because you haven't add the snapshots repositories to your project as the Readme file in the repository says.

    You should be able to fix this issue by adding the following to your top level build.gradle file

    buildscript {
      repositories {
        mavenCentral()
        maven {
          url "https://oss.sonatype.org/content/repositories/snapshots"
        }
      }
      dependencies {
      }
    }
    

    Edit:

    The comment was right, and it wasn't a problem with the repository itself. The problem is that org.threeten:threetenbp:1.3-SNAPSHOT doesn't exist in either repository. ( bintray or snapshots )

    Edit #2:

    Please take a look at this issue on the project

    JakeWharton commented 11 hours ago You need the 1.3-SNAPSHOT of the notzdb branch of the ThreeTenBP project.

    Edit #3:

    Actually, I just saw you are the one that created the issue :) You will need to build it yourself as is not hosted on any repository:

    $ git clone https://github.com/ThreeTen/threetenbp
    $ cd ThreeTen/
    $ git checkout no-tzdb
    $ mvn clean install
    

    Also, is worth mentioning that there are two separated projects for ThreeTen, being the last one the active where the branch is

    https://github.com/ThreeTen/threeten

    https://github.com/ThreeTen/threetenbp