2

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?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
  • 1
    One note about introducing the JSR-310-features on Android: ThreetenBP is not exactly the same as `java.time` in Java-8. For example the Hijri calendar is based on totally different algorithms/data compared with Java-8. Also the general i18n-support is weaker. – Meno Hochschild Jul 15 '15 at 07:04

1 Answers1

2

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

Robert Estivill
  • 12,369
  • 8
  • 43
  • 64
  • Not true! I put `maven{ url 'https://oss.sonatype.org/content/repositories/snapshots/' }` – IgorGanapolsky Jul 14 '15 at 13:54
  • After I follow your steps, I see: Installing E:\git\threetenbp\target\threetenbp-1.3-SNAPSHOT-no-tzdb.jar to C:\Users\Igor\.m2\repository\org\threeten\threetenbp\1.3-SNAPSHOT\threetenbp-1.3-SNAPSHOT-no-tzdb.jar/. So what do I do now to host this dependency on Sonatype? – IgorGanapolsky Jul 14 '15 at 14:45
  • Well, that's not up to you, but up to the team that develops the library. As long as you have the dependency in your local repository you are going to be able to use it on your projects. If you are interested in publishing your libs into Sonatype (or want to rename and package ThreeTen), then you can read http://intohand.com/blog/post/how-to-publish-your-open-source-library-to-maven-central – Robert Estivill Jul 14 '15 at 16:14
  • ~"As long as you have the dependency". Not true. I included the jar in my libs directory, but ThreeTenABP still complains that it expects a Sonatype snapshot!! – IgorGanapolsky Jul 14 '15 at 16:30
  • Including the jar in Lib's doesn't mean Gradle knows it's there. You must have it in your local Maven repository ~/.m2/ so Gradle knows where to pull it from. This is basic dependency management in Maven/Gradle – Robert Estivill Jul 14 '15 at 17:41
  • How is this a scalable and maintainable solution? Every developer on my project will need this dependency in their ~/.m2/ directory. This sucks! – IgorGanapolsky Jul 14 '15 at 17:49
  • 1
    The fact that a library depends on a non hosted, in development version of another library is only relevant for that library developer. If you are not willing to do the same thing then don't use it. Your options are: wait for 1.3 to be final and release, fatjar your lib, include both (310, 310abp and all dependencies) as jars in /libs, or many other ways of getting around this. – Robert Estivill Jul 14 '15 at 18:13
  • 1
    See here: https://twitter.com/JakeWharton/status/621400826523840512 310 1.3 just got released and with it 310ABP. So no need to worry about hosting the dependencies anymore as it's now on Maven http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22threetenbp%22 – Robert Estivill Jul 15 '15 at 19:35