Android Studio javax.mail jar build error

11,505

Solution 1

Add this to your dependencies section:

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

Solution 2

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

There are two libraries available as of right now. You probably only need the first.

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

Note: implementation is just the new standard for compile

Share:
11,505
zic10
Author by

zic10

Updated on June 27, 2022

Comments

  • zic10
    zic10 almost 2 years

    I'm trying to use the Gmail API to send emails. I've followed the Google documentation on how to do this. I need access to MimeMessage which is from the import:

    javax.mail.internet.MimeMessage;

    Since this is not included 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 the jar from there.

    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 pretty sure it has to do with my .jar file reference but I'm not sure how to fix this.

  • Christian
    Christian almost 5 years
    Does the javax.mail.internet.MimeMessage; import stay the same?
  • gumuruh
    gumuruh over 3 years
    ok great.... some tutorial page please....as a reference for this version of javax.mail-api. for adding more upvote. :D
  • gumuruh
    gumuruh over 3 years
    how about additional.jar?
  • Mang Jojot
    Mang Jojot about 2 years
    this work for android studio 4.2.2 +1