我正在自定义Android设备上开发IMAP客户端。所以我决定使用Java Mail库。 我需要从1.4.1版本的Java Mail更新到1.4.5,因为我有大量INBOX文件夹(大约120k邮件)的内存问题。
所以我从官方主页下载了2个jars(mail.jar和activation.jar),我也尝试了发布候选版本1.4.6,但是我无法使它工作。
一旦我构建了整个应用程序,一切都很好,但是当我运行时,这就是它的来源:
2-05 17:31:21.020 19862 19912 I dalvikvm: Failed resolving Ljavax/activation/DataHandler; interface 571 'Ljava/awt/datatransfer/Transferable;'
12-05 17:31:21.030 19862 19912 W dalvikvm: Link of class 'Ljavax/activation/DataHandler;' failed
12-05 17:31:21.030 19862 19912 W dalvikvm: VFY: unable to find class referenced in signature (Ljavax/activation/DataHandler;)
12-05 17:31:21.030 19862 19912 I dalvikvm: Failed resolving Ljavax/activation/DataHandler; interface 571 'Ljava/awt/datatransfer/Transferable;'
12-05 17:31:21.030 19862 19912 W dalvikvm: Link of class 'Ljavax/activation/DataHandler;' failed
12-05 17:31:21.030 19862 19912 E dalvikvm: Could not find method javax.activation.DataHandler.getName, referenced from method javax.mail.internet.MimeUtility.getEncoding
12-05 17:31:21.030 19862 19912 W dalvikvm: VFY: unable to resolve virtual method 4632: Ljavax/activation/DataHandler;.getName ()Ljava/lang/String;
12-05 17:31:21.040 19862 19912 W dalvikvm: VFY: rejecting opcode 0x6e at 0x0004
12-05 17:31:21.040 19862 19912 W dalvikvm: VFY: rejected Ljavax/mail/internet/MimeUtility;.getEncoding (Ljavax/activation/DataHandler;)Ljava/lang/String;
12-05 17:31:21.040 19862 19912 W dalvikvm: Verifier rejected class Ljavax/mail/internet/MimeUtility;
12-05 17:31:21.050 19862 19912 D EMAIL : Releasing mail download wake lock
12-05 17:31:21.050 19862 19912 W dalvikvm: threadid=17: thread exiting with uncaught exception (group=0x4001aa30)
12-05 17:31:21.060 19862 19912 E AndroidRuntime: Uncaught handler: thread pool-1-thread-1 exiting due to uncaught exception
12-05 17:31:21.080 19862 19912 E AndroidRuntime: java.lang.VerifyError: javax.mail.internet.MimeUtility
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:130)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:685)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:636)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at javax.mail.Service.connect(Service.java:295)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at javax.mail.Service.connect(Service.java:176)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at it.kynetics.imwatch.email.imap.EmailAuthenticationImpl.login(EmailAuthenticationImpl.java:36)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at it.kynetics.imwatch.email.imap.EmailConnection.execute(EmailConnection.java:21)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at it.kynetics.imwatch.email.ImCloudEmailService$GetEmailTask.run(ImCloudEmailService.java:148)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
12-05 17:31:21.080 19862 19912 E AndroidRuntime: at java.lang.Thread.run(Thread.java:1060)
12-05 17:31:21.120 1830 1830 I Process : Sending signal. PID: 19862 SIG: 3
我尝试在jar中检查DataHandler和getName方法,一切正常。
有没有人遇到同样的问题?
感谢所有人。
答案 0 :(得分:1)
并非每个java库都适用于Android。您只能使用javamail port for android。最新版本的Javamail尚未移植到Android
答案 1 :(得分:0)
我找到了解决方案!我需要修改mail.jar及其源代码。这是一个“进口包装”问题。在Android移植中,一些mail.jar类从additionalnal.jar导入其他类,其中包名为myjava.awt。 EXC。 在java邮件1.4.5中,该包名为java.awt exc,不包含“my”前缀。解决这个问题,一切都会奏效。
感谢所有人!