Adding Joda Time to Android Studio

不打扰是莪最后的温柔 提交于 2019-11-28 18:27:38

问题


I got the file from the Joda site and followed these instructions for adding libraries but when I get to the Gradle sync I end up with the error:

Gradle Sync

Error:Configuration with name 'default' not found.

Gradle Build

Error:A problem occurred configuring project ':app'. 
> Cannot evaluate module joda : Configuration with name 'default' not found.

A bit confused, I looked around and read that the library should have it's own gradle files but the joda package doesn't. When I try to use import org.joda.time; it can't resolve joda. Does anyone have any idea of what I'm doing wrong?


回答1:


in app/build.gradle file, add like this-

dependencies {    
    compile 'joda-time:joda-time:2.9.4'
}

You don't need to do anything else.

You need the latest release, check out the release page https://github.com/JodaOrg/joda-time/releases and change the version accordingly.




回答2:


I added joda time via File/Project Structure/Modules-App/Dependencies.

Clicking on + and Library dependency brings you to the dialog:

Here you can search for joda and add the actual version to your project. If you add it this way you don't have to manually download the newest version from github or manually write something into your build.gradle file. Android Studio does it all for you.




回答3:


I completely prefer to use jitpack.io repository.

In this case, you should get GitHub links of joda-time (just a simple search) and go to Jitpack.IO then search for the github link.

After all, you should get this page and do the instructions.

https://jitpack.io/#JodaOrg/joda-time/v2.9.4

Just sync your gradle and all done...



来源:https://stackoverflow.com/questions/29237563/adding-joda-time-to-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!