我想在android上使用javamail。我在Windows Java-Project上使用相同的代码,它工作正常。在Android上它不会。如果我使用AsyncTask则无关紧要。
这是LOGCAT:
05-15 06:50:47.605: I/art(1283): Rejecting re-init on previously-failed class java.lang.Class<javax.mail.internet.MimeBodyPart$MimePartDataHandler>
05-15 06:50:47.607: I/art(1283): Rejecting re-init on previously-failed class java.lang.Class<javax.mail.internet.MimeBodyPart$MimePartDataHandler>
05-15 06:50:47.738: I/art(1283): Rejecting re-init on previously-failed class java.lang.Class<javax.mail.internet.MimeBodyPart$MimePartDataHandler>
05-15 06:50:47.747: I/art(1283): Rejecting re-init on previously-failed class java.lang.Class<javax.mail.internet.MimeBodyPart$MimePartDataHandler>
05-15 06:50:47.756: I/art(1283): Rejecting re-init on previously-failed class java.lang.Class<javax.mail.internet.MimeBodyPart$EncodedFileDataSource>
05-15 06:50:47.756: I/art(1283): Rejecting re-init on previously-failed class java.lang.Class<javax.mail.internet.MimeBodyPart$EncodedFileDataSource>
05-15 06:50:47.770: I/art(1283): Rejecting re-init on previously-failed class java.lang.Class<javax.mail.internet.MimeBodyPart$MimePartDataHandler>
05-15 06:50:47.802: D/AndroidRuntime(1283): Shutting down VM
05-15 06:50:47.833: E/AndroidRuntime(1283): FATAL EXCEPTION: main
05-15 06:50:47.833: E/AndroidRuntime(1283): Process: de.seidlc.sms_mail_gateway, PID: 1283
05-15 06:50:47.833: E/AndroidRuntime(1283): java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/activation/DataHandler;
05-15 06:50:47.833: E/AndroidRuntime(1283): at javax.mail.internet.MimeMessage.setContent(MimeMessage.java:1516)
05-15 06:50:47.833: E/AndroidRuntime(1283): at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:1176)
05-15 06:50:47.833: E/AndroidRuntime(1283): at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1555)
05-15 06:50:47.833: E/AndroidRuntime(1283): at javax.mail.internet.MimeMessage.setText(MimeMessage.java:1539)
...
05-15 06:50:47.833: E/AndroidRuntime(1283): at android.view.View.performClick(View.java:4780)
05-15 06:50:47.833: E/AndroidRuntime(1283): at android.view.View$PerformClick.run(View.java:19866)
05-15 06:50:47.833: E/AndroidRuntime(1283): at android.os.Handler.handleCallback(Handler.java:739)
05-15 06:50:47.833: E/AndroidRuntime(1283): at android.os.Handler.dispatchMessage(Handler.java:95)
05-15 06:50:47.833: E/AndroidRuntime(1283): at android.os.Looper.loop(Looper.java:135)
05-15 06:50:47.833: E/AndroidRuntime(1283): at android.app.ActivityThread.main(ActivityThread.java:5257)
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.reflect.Method.invoke(Native Method)
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.reflect.Method.invoke(Method.java:372)
05-15 06:50:47.833: E/AndroidRuntime(1283): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-15 06:50:47.833: E/AndroidRuntime(1283): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-15 06:50:47.833: E/AndroidRuntime(1283): Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.activation.DataHandler" on path: DexPathList[[zip file "/data/app/de.seidlc.sms_mail_gateway-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
05-15 06:50:47.833: E/AndroidRuntime(1283): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
05-15 06:50:47.833: E/AndroidRuntime(1283): ... 17 more
05-15 06:50:47.833: E/AndroidRuntime(1283): Suppressed: java.lang.ClassNotFoundException: javax.activation.DataHandler
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.Class.classForName(Native Method)
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
05-15 06:50:47.833: E/AndroidRuntime(1283): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
05-15 06:50:47.833: E/AndroidRuntime(1283): ... 18 more
05-15 06:50:47.833: E/AndroidRuntime(1283): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
05-15 06:50:51.469: I/Process(1283): Sending signal. PID: 1283 SIG: 9