I am building an app that uses time. I decided to use Joda time. I am trying to add joda time to my app. I have no experience with adding .jar
files to the libs. I followed these steps(see bottom), or so I thought. My project is showing no errors, but when I run a simple test: DateTime test = new DateTime();
I get a force close and the following error:
Could not find class 'org.joda.time.DateTime', referenced from method xxxx
java.lang.NoClassDefFoundError: org.joda.time.DateTime
These are the steps I followed:
- Create your android project in eclipse.
- Download Joda Time
- In Eclipse look for your project at package explorer and right click on it then call it
New -> Folder -> libs
. Note: I did not do this because I already had a folder named libs
- Copy (or) drag & drop the
joda-time-2.1.jar
into the newly created libs
folder.
- Right click on your project again (in package explorer) then
Properties -> Java Build Path -> Libraries -> Add Jars -> joda-time-2.1.jar
.
Now you can test with this code :
DateTime test = new DateTime();
After importing:
import org.joda.time.DateTime;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…