5

我使用 javamail api for 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 库......我怎样才能将它们添加到我的项目中,以便我可以导出我的项目并对其进行混淆?

非常感谢你!

更新:

我尝试在我的项目中导入 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 

我能做些什么?

4

2 回答 2

11

列出的 java 类不是 Android 运行时的一部分。最干净的解决方案是从 javamail 库中删除引用它们的类,因为它们永远无法在这种环境中工作。

通常,您也可以在 ProGuard 配置中将它们过滤掉,但 Android 构建脚本不支持过滤器。

作为一个简单的替代方法,您可以禁止显示警告:

-dontwarn java.awt.**,javax.security.**,java.beans.**

ProGuard 将继续进行而不会抱怨。

于 2011-03-23T22:05:22.280 回答
4

我已经通过在项目中添加 jre 库并将此命令添加到 proguard.cfg 文件十解决了这个问题:

-libraryjars <java.home>/lib/rt.jar(java/**,javax/security/**,javax/activation/**)

希望这对某人有帮助:P

于 2011-03-23T06:04:16.353 回答