Search code examples
javaandroidgmailjakarta-mailgmail-imap

Android - JavaMail with Gmail ID


I'm writing an application which will need to be able to receive email from a specific account (in this instance Gmail) and get the unique Gmail ID of each message in order for it to create a link to that message for future reference.

All of this can be done in Java using the JavaMail API and the GmailMessage class and connecting via 'gimaps'. However this API doesn't compile when imported into my Android application - Unable to execute dex: Multiple dex files define Lcom/sun/mail/iap/AString I get different variations of these depending on which jars I try to import (pop3, imap, gimap etc)

Searching around it seems I need to use one of the JavaMail android ports however none of them have the ability to grab the Gmail unique message id.

So my question is does anyone know of a way to do this on Android, using either the official JavaMail API (if that's possible) or using on the various ports?

Thanks.

EDIT: Thanks, actually I've got it partially working using a port found here https://code.google.com/p/java-gmail-imap/ however it crashes when trying to grab the body of text from the email. I know this is due to the same files missing that are corrected in this port https://code.google.com/p/javamail-android/ I've checked out the java-gmail-imap code into eclipse to try and add the missing classes from the android port but everytime I export I get java.lang.NoClassDefFoundError: com.google.code.javax.mail.Session

Opening the jar file this class is present.. anyone know what I could be doing wrong?


Solution

  • I managed to get this working using the library found here and changing some of the imports to the myjava.* imports from the Android Java Mail port.