Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Joda Time to Android Studio

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?

like image 838
Cai Avatar asked Mar 24 '15 16:03

Cai


People also ask

What is Joda Time Android?

For Android developers Joda-Time solves one critical problem: stale timezone data. Built-in timezone data is only updated when the OS is updated, and we all know how often that happens. Countries modify their timezones all the time; being able to update your own tz data keeps your app up-to-date and accurate.


2 Answers

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.

like image 193
Amit K. Saha Avatar answered Oct 09 '22 18:10

Amit K. Saha


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

enter image description here

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

enter image description here

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.

like image 40
Christian Avatar answered Oct 09 '22 19:10

Christian