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

android:当minify为真时不发送邮件

如何解决android:当minify为真时不发送邮件

尝试使用 javax.mail 包。当 minify 为 false 时,发送邮件。当 minify 为 true 时,不发送邮件

这是 AsyncTask doinbackground。当 minify 为 true 时,异常消息为“smtp”。

2021-03-31 14:52:35.196 26564-26652/? W: javax.mail.NoSuchProviderException: smtp
2021-03-31 14:52:35.196 26564-26652/? W:     at     javax.mail.Session.getService(UnkNown Source:138)
2021-03-31 14:52:35.196 26564-26652/? W:     at     javax.mail.Session.getTransport(UnkNown Source:10)
2021-03-31 14:52:35.196 26564-26652/? W:     at     javax.mail.Session.getTransport(UnkNown Source:8)
2021-03-31 14:52:35.196 26564-26652/? W:     at     javax.mail.Session.getTransport(UnkNown Source:12)
2021-03-31 14:52:35.196 26564-26652/? W:     at     javax.mail.Session.getTransport(UnkNown Source:14)
2021-03-31 14:52:35.196 26564-26652/? W:     at     javax.mail.Transport.send0(UnkNown Source:61)
2021-03-31 14:52:35.196 26564-26652/? W:     at javax.mail.Transport.send(UnkNown Source:7)
2021-03-31 14:52:35.196 26564-26652/? W:     at     com.maor.cohen.utils.EmailUtils$SendMailTask.doInBackground(UnkNown     Source:3)
2021-03-31 14:52:35.196 26564-26652/? W:     at     com.maor.cohen.utils.EmailUtils$SendMailTask.doInBackground(UnkNown     Source:2)
2021-03-31 14:52:35.196 26564-26652/? W:     at android.os.AsyncTask$3.call(AsyncTask.java:378)
2021-03-31 14:52:35.196 26564-26652/? W:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2021-03-31 14:52:35.196 26564-26652/? W:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
2021-03-31 14:52:35.196 26564-26652/? W:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2021-03-31 14:52:35.196 26564-26652/? W:     at     java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2021-03-31 14:52:35.196 26564-26652/? W:     at java.lang.Thread.run(Thread.java:919)

异步任务 doInBackground:

protected Void doInBackground(javax.mail.Message... messages) {
        try {
            Transport.send(messages[0]);
        } catch (MessagingException e) {
            Log.d("log_tag","excpetion sending mail: " + e.getLocalizedMessage());
            e.printstacktrace();
        }
        return null;
    }

添加了 proguard:

-keep class javax.** {*;}
-keep class javax.* {*;}
-keep class javax.mail.* {*;}

但还没有成功发送邮件

知道如何解决这个问题吗? minify 必须是真的,并且应该在那里添加更多的东西。

解决方法

Javamail 规则

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

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