我使用javamail api为android创建了一个邮件客户端,该应用程序在模拟器或设备中运行良好...现在我想使用eclipse导出项目但是我遇到了以下错误:
Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable
Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard
Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient
Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslException
Warning: org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point
Warning: org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext
Warning: org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceEvent
正如我所看到的,javamail api使用java.awt和javax.security libs ...如何在项目中添加它们以便我可以导出我的项目并对其进行模糊处理?
非常感谢!
更新:
我尝试在我的项目中导入jre库,但这些错误已经消失,但新的错误已经出现了:
Proguard returned with error code 1. See console
Note: there were 4243 duplicate class definitions.
Warning: library class com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler extends or implements program class javax.activation.DataContentHandler
Warning: library class com.sun.xml.internal.ws.encoding.XmlDataContentHandler extends or implements program class javax.activation.DataContentHandler
Warning: library class com.sun.xml.internal.messaging.saaj.soap.MessageImpl$1 extends or implements program class javax.activation.DataSource
Warning: library class com.sun.xml.internal.ws.encoding.StringDataContentHandler extends or implements program class javax.activation.DataContentHandler
我该怎么办?
答案 0 :(得分:11)
列出的java类不是Android运行时的一部分。最干净的解决方案是从javamail库中删除引用它们的类,因为它们永远不能在这种环境中工作。
通常,您也可以在ProGuard配置中过滤掉它们,但Android构建脚本不支持过滤器。
作为一种简单的替代方法,您可以取消警告:
-dontwarn java.awt.**,javax.security.**,java.beans.**
ProGuard将继续进行而不会抱怨。
答案 1 :(得分:4)
我通过在项目中添加jre库解决了这个问题,并且将这个命令添加到proguard.cfg文件中:
-libraryjars <java.home>/lib/rt.jar(java/**,javax/security/**,javax/activation/**)
希望这有助于某人:P