Error: Gradle: Error: package javax.mail does not exist
How can I get .jar files from javamail?
I am using intelliJ IDEA IDE and trying to navigate to project structure - libraries - add .jar files and save. Then I went into modules and checked the boxes under the export simply because the support library I use for snippets etc. was checked.
I used the code Sending Email on Android using JavaMail API without using the stock / built-in app , but no luck.
I've tried using the .jar files intact as well as after extraction, but both fail with the same error.
I don't get an error in code edit mode only when compilation fails with gradle error and presents me with an error ", error (3.6): Gradle: error: javax. Mail package does not exist. Please help!
I also tried to follow the instructions How to use external JAR files in an Android project? but I think these directions are for the Eclipse IDE.
edt: gradle -build:
Information:Compilation completed with 25 errors and 0 warnings in 25 sec
Information:25 errors
Information:0 warnings
Error:Gradle: Execution failed for task ':app:compileDebugJava'.
Compilation error; see compiler error output. C: \ Users \ Marcus \ Documents \ IdeaProjects \ Android \ TestProjects \ TestMailFeature3 \ app \ SRC \ home \ Java \ com \ majorwit \ testmailfeature3 \ app \ GMailSender.java
Error:(3, 24) Gradle: error: package javax.activation does not exist
Error:(4, 24) Gradle: error: package javax.activation does not exist
Error:(5, 18) Gradle: error: package javax.mail does not exist
Error:(6, 18) Gradle: error: package javax.mail does not exist
Error:(7, 18) Gradle: error: package javax.mail does not exist
Error:(8, 18) Gradle: error: package javax.mail does not exist
Error:(9, 27) Gradle: error: package javax.mail.internet does not exist
Error:(10, 27) Gradle: error: package javax.mail.internet does not exist
Error:(18, 44) Gradle: error: package javax.mail does not exist
Error:(22, 13) Gradle: error: cannot find symbol class Session
Error:(46, 15) Gradle: error: cannot find symbol class PasswordAuthentication
Error:(67, 49) Gradle: error: cannot find symbol class DataSource
Error:(43, 19) Gradle: error: cannot find symbol variable Session
Error:(47, 20) Gradle: error: cannot find symbol class PasswordAuthentication
Error:(52, 13) Gradle: error: cannot find symbol class MimeMessage
Error:(52, 39) Gradle: error: cannot find symbol class MimeMessage
Error:(53, 13) Gradle: error: cannot find symbol class DataHandler
Error:(53, 39) Gradle: error: cannot find symbol class DataHandler
Error:(54, 35) Gradle: error: cannot find symbol class InternetAddress
Error:(58, 46) Gradle: error: package Message does not exist
Error:(58, 65) Gradle: error: cannot find symbol variable InternetAddress
Error:(60, 45) Gradle: error: package Message does not exist
Error:(60, 68) Gradle: error: cannot find symbol class InternetAddress
Error:(61, 13) Gradle: error: cannot find symbol variable Transport
source to share
The javax.activation and javax.mail packages are not part of the standard Android packages ( http://developer.android.com/reference/packages.html ).
Fortunately, the Android version from JavaMail has been released ( https://java.net/projects/javamail/pages/Android ). I followed the suggestion to change the build.gradle file for my project in Android Studio and was able to compile successfully without having to manually download the jar files.
android {
packagingOptions {
pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
}
repositories {
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
}
source to share
I added the following to my build.gradle (Module: app) file and it compiled without error.
dependencies {
//other dependencies here...
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
One diff is that in my case it is an Android project.
source to share