3

我正在使用 gmailsender 在我的应用程序中发送电子邮件。我按照下面的链接在 Android 中使用 JavaMail API 发送电子邮件,而不使用默认/内置应用程序

然而,我注意到,每当我使用 proguard 构建我的 APK 时,gmail 发件人都不起作用(当我安装该 APK 时)。没有抛出错误,但没有发送电子邮件。如果我禁用 proguard 然后生成 APK,那么使用该 APK 可以正常工作。

谁能建议这里可能有什么问题。

:::EDIT:::-在生成 APK 时从控制台添加了一些错误消息(删节)行。但是,我可以通过在 PROGUARD CONFIG 文件中忽略它们来摆脱这些警告

[2013-07-09 10:00:38 - ] Proguard returned with error code 1. See console
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find 
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.auth.callback.NameCallback
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmCallback
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmChoiceCallback
[2013-07-09 10:00:38 - ] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
[2013-07-09 10:00:38 - ] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ]       You should check if you need to specify additional program jars.
[2013-07-09 10:00:38 - ] Warning: there were 247 unresolved references to classes or interfaces.
[2013-07-09 10:00:38 - ]          You may need to specify additional library jars (using '-libraryjars').
[2013-07-09 10:00:38 - ] java.io.IOException: Please correct the above warnings first.
[2013-07-09 10:00:38 - ]    at proguard.Initializer.execute(Initializer.java:321)
[2013-07-09 10:00:38 - ]    at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-07-09 10:00:38 - ]    at proguard.ProGuard.execute(ProGuard.java:86)
[2013-07-09 10:00:38 - ]    at proguard.ProGuard.main(ProGuard.java:49
4

1 回答 1

15

最后通过将 proguard 的最新版本从 4.7 更新到 4.9 解决了这个问题。

还将以下内容添加到 proguard 配置文件中

-dontwarn java.awt.**
-dontwarn java.beans.Beans
-dontwarn javax.security.**
-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}
-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class mimetypes.** {*;}
-keep class myjava.awt.datatransfer.** {*;}
-keep class org.apache.harmony.awt.** {*;}
-keep class org.apache.harmony.misc.** {*;}
于 2013-07-10T18:45:41.850 回答