Android的,Proguard的和JAVAMAIL [英] Android, Proguard and Javamail

查看:414
本文介绍了Android的,Proguard的和JAVAMAIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我已经来过提到了类似的帖子,的Andr​​oid,JavaMail的和proguard的

First off, i've already to referred to a similar post, Android, javamail and proguard

中提到的解决方案是明确地保持ProGuard的-project.txt以下内容:

The solution mentioned was to explicitly keep the following in proguard-project.txt:

-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.** {*;}

乍一看,这似乎是工作,因为它没有任何警告编译。然而,它不能在阅读邮件内容,只是右跳过去。我已经试过如下:

At first sight, this seemed to work, as it compiled without any warnings. However, it fails at reading the message content and just skips right over it. I've tried the following:


  1. -includelibraryjars明确命名的JavaMail所需的三个文件。

  2. -removed罐子作为外部库,继新库/包括格式。

  3. -maintained在默认的Andr​​oid设置的ProGuard-android.txt

  4. -followed在ProGuard的常见问题故障排除指南。

  5. -started一个新的项目和复制的源文件了。

  6. -tried各种ProGuard的选项,包括-dontshrink,keepnames等

  7. -obsessive项目/洁净

挫折的几个小时后,这里是我发现,似乎工作:

After a few hours of frustration, here's what i found that seemed to work:

-dontobfuscate
-dontshrink
-keepdirectories
-keeppackagenames javax.mail.**
-keeppackagenames javax.activation.**
-keeppackagenames com.sun.mail.**
-keeppackagenames myjava.**
-keeppackagenames org.apache.harmony.**
-keeppackagenames mailcap.**
-keeppackagenames mimetypes.**
-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.** {*;}

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

当然,因为我打开-dontobfuscate和-dontshrink这是荒唐。任何ProGuard,并将JavaMail的大师有一个解决的办法?我ADT17,使用2.1(api7)的构建。如果我能完全从过程也许排除罐子?任何意见将是在这一点上一大福音。

Of course that's absurd because i'm turning on -dontobfuscate and -dontshrink. Any proguard and javamail gurus have a solution to this? I'm ADT17, using 2.1(api7) for the build. If i could exclude the jars entirely from the process maybe? Any advice will be a godsend at this point.

推荐答案

问题解决了。我已经发布了解决方案,这里有在上面的链接提到的其他解决的问题的人。

Problem solved. I've posted the solution here for anyone having issues with the other solution mentioned in the link above.

因为我用用JavaMail(Mail.java)一个辅助类,我需要包括类作为-keep,这样它会工作。我编辑在的Andr​​oid,JavaMail的和proguard的以包括辅助类,因为许多使用这和其他的解决方案可能会失败,可怕的没有它。

Because i was using a helper class with javamail (Mail.java), i needed to include that class as a -keep so that it would work. I edited the solution provided at Android, javamail and proguard to include the helper class, since many use this and the other solution may fail horribly without it.

在您的ProGuard-project.txt文件将这个。我以其它方式使用默认的Andr​​oid设置。

Put this in your proguard-project.txt file. I used the default android settings otherwise.

-dontshrink
-keep class javax.** {*;}
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.harmony.** {*;}
-keep public class Mail {*;}
-dontwarn java.awt.**
-dontwarn java.beans.Beans
-dontwarn javax.security.**

这篇关于Android的,Proguard的和JAVAMAIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆