我正在尝试使用 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'
我收到编译错误:
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
以前有人在 Android 中成功使用过这个库吗?
最佳答案
这是构建过程的问题,无法下载依赖项。
这很可能是由于您没有将快照存储库添加到项目中而导致的 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 在两个存储库中都不存在。 ( bintray 或 snapshots )
编辑#2:
请查看this issue关于项目
JakeWharton commented 11 hours ago You need the 1.3-SNAPSHOT of the notzdb branch of the ThreeTenBP project.
编辑#3:
事实上,我刚刚看到你是造成这个问题的人:) 您需要自己构建它,因为它没有托管在任何存储库上:
$ git clone https://github.com/ThreeTen/threetenbp
$ cd ThreeTen/
$ git checkout no-tzdb
$ mvn clean install
此外,值得一提的是,ThreeTen 有两个独立的项目,最后一个是分支所在的 Activity 项目
关于android - 无法编译 ThreeTenABP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31408516/