1

i am doing an application-email sending without user interaction. so that i got coding from the following link. here i got java.lang.NoClassDefFoundError: com.murali.email.GMailSender. i got this error at

GMailSender sender = new GMailSender("username@gmail.com", "password");
                    sender.sendMail("This is Subject",   
                            "This is Body",   
                            "user@gmail.com",   
                            "user@yahoo.com");  

in the MailSenderActivity Class. i added all external jars in referenced library and no error found at compile time. i spent more time to solve the issue but failed. i know it is possible of duplicate question but the other answers were not used for me. i guess me or eclipse miss some jar or class path for GMailSender class. please help me. i do not know how to solve it.

Community
  • 1
  • 1
M.A.Murali
  • 9,158
  • 30
  • 98
  • 169
  • Does GMailSender come from an other Eclipse project as a library project / external jar? If yes, set that project to export the jar – ᆼᆺᆼ May 09 '12 at 18:58

2 Answers2

9

Make sure the jar sits in a folder named libs, not lib. Then perform "clean" and make sure the jar appears under Android dependencies.

avimak
  • 1,608
  • 11
  • 18
  • You are wrong. When using the latest ADT it seems that jar files in `lib` won't get included under Android dependencies, and it can cause the above exception. – avimak May 09 '12 at 19:03
  • Here is a thread about the subject - [link](http://stackoverflow.com/questions/2247998/noclassdeffounderror-eclipse-and-android) – avimak May 09 '12 at 19:35
  • Even in that question there are many answers stating they solved the problem without moving the jars – ᆼᆺᆼ May 10 '12 at 08:12
  • thanks, i created a new project with libs folder now its works! – M.A.Murali May 10 '12 at 08:26
  • Of course there are many other ways to "achieve" `java.lang.NoClassDefFoundError`... but the last ADT upgrade surly contributed its part and I think it better to deny this case before proceeding any further – avimak May 10 '12 at 08:27
2

If we get this error on android

java.lang.NoClassDefFoundError: javax.activation.DataHandler referenced from method javax.mail.internet.MimeMessage.updateHeaders

We need to add aditional.jar along with mail.jar and activation.jar. This solved my issue in android when accessing MimeMultipart.

j0k
  • 21,914
  • 28
  • 75
  • 84
Anil R
  • 21
  • 2