微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – gmailsender在使用proguard时无法正常工作

我正在使用gmailsender在我的应用中发送电子邮件.我按照下面的链接Sending Email in Android using JavaMail API without using the default/built-in app

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

任何人都可以建议这里可能有什么问题.

:::编辑::: – 添加少量错误消息(删节)来自控制台的线路,同时生成APK.我可以通过在PROGUARD配置文件中忽略它们来避免这些警告

[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.7到4.9更新到最新版本的proguard解决了这个问题.

还将以下内容添加到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.** {*;}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐