无法编译ThreeTenABP

时间:2015-07-14 13:46:55

标签: android gradle sonatype threetenbp

我正在尝试使用Jake Wharton的ThreeTenABP库 - https://github.com/JakeWharton/ThreeTenABP - 用于我的Android项目中的JSR310日期/时间功能。该库的主要优点是它比Jodatime(http://www.joda.org/joda-time/)和threetenbp(https://github.com/ThreeTen/threetenbp)具有更少的编译开销。但是,ThreeTenABP库在我的项目中没有编译。我在build.gradle中添加以下内容:

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

我收到编译错误:

  

错误:无法找到org.threeten:threetenbp:1.3-SNAPSHOT。   要求:       MyApp的:应用程序:未指定       MyApp:app:未指定> com.jakewharton.threetenabp:threetenabp:1.0.0-SNAPSHOT   在build.gradle文件中搜索

以前有人在Android中成功使用过这个库吗?

1 个答案:

答案 0 :(得分:2)

这是构建过程的问题,无法下载依赖项。

这很可能是因为您没有将快照存储库添加到项目Readme file in the repository says

您应该可以通过将以下内容添加到顶级build.gradle文件

来解决此问题
buildscript {
  repositories {
    mavenCentral()
    maven {
      url "https://oss.sonatype.org/content/repositories/snapshots"
    }
  }
  dependencies {
  }
}

编辑:

评论是正确的,这对存储库本身来说不是问题。 问题是org.threeten:threetenbp:1.3-SNAPSHOT在两个存储库中都不存在。 (bintraysnapshots

编辑#2:

请查看项目中的this issue

  

JakeWharton在11小时前评论过您需要1.3-SNAPSHOT   ThreeTenBP项目的notzdb分支。

编辑#3:

实际上,我刚刚看到你是创造这个问题的人:) 您需要自己构建它,而不是托管在任何存储库中:

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

另外,值得一提的是,ThreeTen有两个独立的项目,是分支机构活跃的最后一个项目

  

https://github.com/ThreeTen/threeten

     

https://github.com/ThreeTen/threetenbp