java.lang.NoClassDefFoundError: javax.activation.DataHandler in android
There is an Android-friendly port of javamail which you should be using. There are three libraries that you need to include in your app: mail.jar, activation.jar, and additionnal.jar(sic). It looks like you are missing something that the activation library depends on, and this could be because you are not using the Android port of this library.
I have used the Android-friendly version of javamail successfully in a project, and it works really well.
Sending Mail in Android throwing java.lang.NoClassDefFoundError: javax.activation.DataHandler
It appears that you are using an old approach. If so, you are missing a jar.
See javamail
for Android here:
https://code.google.com/archive/p/javamail-android/downloads
Note: the above project is old and probably not supported anymore.
If you want to use the new JavaMail 1.6.0, which has Android support, you can grab the javax.mail.jar
here:
https://github.com/javaee/javamail/releases
Then, simply add the dependencies to your gradle file:
dependencies {
compile 'com.sun.mail:android-mail:1.6.0'
compile 'com.sun.mail:android-activation:1.6.0'
}
NoclassDefFound:javax.activation.DataHandler
Paste your external jar in libs
directory and then give path
from your libs directory
right click on project
-->properties
-->java build path
-->add external jar's
-->select your libs
directory
Eclipse: java.lang.NoClassDefFoundError: javax/activation/DataHandler
JDK 9 disables access to many of the javax.* APIs by default, javax activation is now deprecated.
However you can resolve it with adding the module at run time
"--add-modules java.activation".
java.lang.NoClassDefFoundError: javax/activation/DataContentHandler
Just include the java.activation module in your application.
You can use either the older Oracle version, or the newer Eclipse version, which is essentially the same.
(And you should consider upgrading to JDK 11.)
Related Topics
How to Create a Http Server in Android
Missing "<Sdk>/Extras/Google/Google_Play_Services/Libproject" Folder After Update to Revision 30
How to Set Internet Options for Android Emulator
Edittext: Disable Paste/Replace Menu Pop-Up on Text Selection Handler Click Event
Android Adb Device Offline, Can't Issue Commands
Any Way to Run Shell Commands on Android Programmatically
Android Usb Host and Hidden Devices
How to Restrict Android App to Specific Device Make
Cursor Size Limit in Android SQLitedatabase
Android: How to Convert String to Date
Android Studio - Importing External Library/Jar
Removing Log Call Using Proguard
The Signing Fingerprint You Specified Is Already Used by Another Android Oauth2 Client
Navigation Drawer: How to Set the Selected Item at Startup