Error creating javax.mail jar for Android Studio

I am trying to use the Gmail API to send emails. I followed google documentation on how to do this. I need access to MimeMessage, which is from import:

javax.mail.internet.MimeMessage;

Since this is not enabled by default in Android Studio, I downloaded the .jar files and did.

File -> New -> New Module -> Import .JAR

I also physically placed the javax.jar in the libs folder in Android Studio and referenced it.

my build.gradle (app) file looks like this in the dependencies section:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.google.api-client:google-api-client:1.20.0'
    compile 'com.google.api-client:google-api-client-android:1.20.0'
    compile 'com.google.api-client:google-api-client-gson:1.20.0'
    compile 'com.google.apis:google-api-services-gmail:v1-rev29-1.20.0'
    compile project(':javax.mail')
}

      

However, when I clean and build the project, I get this error:

com.android.ide.common.ProcessException: org.gradle.Internal.ExecException.

I googled this and I'm sure it has something to do with my .jar link, but I'm not sure how to fix it.

+3


source to share


2 answers


Add this to the dependencies section:



compile  'javax.mail:javax.mail-api:1.5.3'

      

+9


source


They now have a library built for Android only, which you can find here: https://javaee.github.io/javamail/Android

There are currently two libraries available. You probably only want the former.



implementation 'com.sun.mail:android-mail:1.6.0'
implementation 'com.sun.mail:android-activation:1.6.0'

      

Note: implementation

- this is only a new standard forcompile

0


source







All Articles