Java.Lang.Noclassdeffounderror: Javax.Activation.Datahandler in Android

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.

javamail

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



Leave a reply



Submit