Status Update
Comments
ja...@google.com <ja...@google.com> #2
Thank you for reporting this issue. For us to further investigate this issue, please go over the data below carefully and provide the following additional information:
Please fill out each question and comment, thank you.
-
Have you observed this bug on Pixel devices as well?
-
Android Build Version (go to Settings > About Device > Build Number (hold down to copy))
-
Android Device Model:
-
Android app name and version if an app related issue:
-
Capture the issue in a screen recording (desktop and/or phone capture).
-
Upload the full bug report file. Steps followed here:
https://developer.android.com/studio/debug/bug-report -
Please provide a simple sample project that reproduces the issue (this gives us the closest test environment to yours which will help analyze your issue).
-
Steps to reproduce issue with provided sample project: [Be as specific as possible]
- 1
- 2
- 3
-
Expected Results:
-
Observed Results:
Note: Please upload to google drive and share the folder to
The more information we have, the more accurately our product and engineering team can solve the issue. Thank you for your cooperation.
in...@gmail.com <in...@gmail.com> #3
Yes, it occurs on the Pixel 3a running Android 11.
Android Build Version (go to Settings > About Device > Build Number (hold down to copy))
Build Number RP1A.201105.002
Android Device Model:
PIxel 3a
Android app name and version if an app related issue:
Not relevant as the issue is not present in the current released production app
Capture the issue in a screen recording (desktop and/or phone capture).
Is this really necessary as the app just quits / crashes?
Upload the full bug report file. Steps followed here:
I will follow up with this soon.
Please provide a simple sample project that reproduces the issue (this gives us the closest test environment to yours which will help analyze your issue).
Here's the sample app. However you will need to create a Google Console Project with the package name (com.example.testjavamail) and the debug SHA fingerprint for your Android Studio, and add enable the GMail API with the Send Messages permission. The test app has the user select a Google Account to authorize to send messages from.
Steps to reproduce issue with provided sample project: [Be as specific as possible]
1. Tap the Not Set red button to select a Google Account
2 Accept the Google Gmail send message authorization. The app should attempt to send an email to your Google account stating that the email is working for the app
3. A Send test email button will appear. Tap it to try sending an email again.
Expected Results:
The app sends and email to your Gmail account verifying that your account has been authorized to use with the app
Observed Results: The app crashes when trying to create and send the email. This only happens when the project targets SDK 30. If you target 29 or lower and run the app, it works fine.
ja...@google.com <ja...@google.com> #4
Upload the full bug report file. Steps followed here:
I will follow up with this soon.
Thank you we will await your bug report.
ja...@google.com <ja...@google.com> #5
Thank you for reporting this issue. We’ve shared this with our product and engineering teams and will continue to provide updates as more information becomes available.
in...@gmail.com <in...@gmail.com> #6
The bug report was generated while running
the com.apps.ips.teachernotes3 package which is my app that has this
issue. This app is different from the sample app I included earlier,
although I used the exact same code in the app for the sample app. Let me
know if you need anything else.
In Pocket Solutions
*Apps designed by a teacher, for teachers*
w <inpocketsolution@gmail.com>ww.i <
facebook <
On Thu, Nov 5, 2020 at 1:05 PM <buganizer-system@google.com> wrote:
ja...@google.com <ja...@google.com> #7
Thank you for the update. Please share the folder to
in...@gmail.com <in...@gmail.com> #8
ja...@google.com <ja...@google.com> #9
Thank you for the update. We’ve shared this with our product and engineering teams and will continue to provide updates as more information becomes available.
ng...@google.com <ng...@google.com> #10
Caused by: java.lang.VerifyError: Verifier rejected class com.sun.mail.handlers.handler_base: java.awt.datatransfer.DataFlavor[] com.sun.mail.handlers.handler_base.getTransferDataFlavors() failed to verify: java.awt.datatransfer.DataFlavor[] com.sun.mail.handlers.handler_base.getTransferDataFlavors(): [0x4] can't resolve returned type 'Unresolved Reference: java.awt.datatransfer.DataFlavor[]' or 'Reference: javax.activation.ActivationDataFlavor[]' (declaration of 'com.sun.mail.handlers.handler_base' appears in /data/app/~~RLNZ6uodnEsYCb6GewenIg==/com.example.testjavamail-YKeE7WfbGlx0yA3z6ZNvGA==/base.apk)
This is WAI. In SDK 30, we've added a check to ensure the returned type is resolved. java.awt.* and javax.activation.* aren't APIs from Android, so unless you put them in your app, it's expected that they don't resolve. And even though the method at fault may never be executed, in SDK30 we've made things more strict on the return type for correctness.
If indeed you don't define java.awt.datatransfer.DataFlavor and/or javax.activation.ActivationDataFlavor in your app, I suggest you just remove the method referencing those classes. It is likely dead code.
ja...@google.com <ja...@google.com>
in...@gmail.com <in...@gmail.com> #11
I literally followed Google's only reference code for sending emails here.
So if this code does not work for SDK 30, it should really be updated so it works correctly for developers instead of each developer trying to figure out things for themselves. Here are the two methods I'm using here.
The crash / bug is happening in the second method at this line : emailContent.writeTo(buffer);
public static MimeMessage createEmail(String to,
String from,
String subject,
String bodyText)
throws MessagingException {
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage email = new MimeMessage(session);
email.setFrom(new InternetAddress(from));
email.addRecipient(
new InternetAddress(to));
email.setSubject(subject);
email.setText(bodyText);
return email;
}
public static Message createMessageWithEmail(MimeMessage emailContent)
throws MessagingException, IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
emailContent.writeTo(buffer);
byte[] bytes = buffer.toByteArray();
String encodedEmail = Base64.encodeBase64URLSafeString(bytes);
Message message = new Message();
message.setRaw(encodedEmail);
return message;
}
ng...@google.com <ng...@google.com> #12
in...@gmail.com <in...@gmail.com> #13
in...@gmail.com <in...@gmail.com> #14
'com.sun.mail:android-mail:1.6.5'
'com.sun.mail:android-activation:1.6.5'
I've tried about 4 different javamail dependencies and they all have the same issue.
While I can get by targeting SDK 29 for now, but this time next year all apps will have have to target SDK 30 and then I'll have a real problem.
wa...@gmail.com <wa...@gmail.com> #15
Could you explain it started working a bit when I changed:
msg.setText("This is a test");
to:
// A.11 = works =>
msg.setContent("This is a test", "plain/text; charset=utf-8");
Anyway I had problems with adding attachments or sending as XML.
Only API 30 Android 11 has this problem.
wi...@bemobiled.com <wi...@bemobiled.com> #16
ni...@gmail.com <ni...@gmail.com> #17
-keep class com.sun.mail.imap.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class javax.activation.** {*;}
-dontwarn com.sun.mail.**
-dontwarn org.apache.harmony.awt.**
-dontwarn javax.security.sasl.**
-dontwarn java.awt.**
-dontwarn java.beans.**
in...@gmail.com <in...@gmail.com> #18
[Deleted User] <[Deleted User]> #19
the proguard configuration mentioned above didn't help me,
any other way to solve this?
m....@gmail.com <m....@gmail.com> #20
bs...@gmail.com <bs...@gmail.com> #21
am...@gmail.com <am...@gmail.com> #22
mo...@cdip.com <mo...@cdip.com> #23
implementation 'com.sun.mail:android-mail:1.6.6'
implementation 'com.sun.mail:android-activation:1.6.6'
eu...@paulo.costa.nom.br <eu...@paulo.costa.nom.br> #24
This works, Thanks!
bs...@gmail.com <bs...@gmail.com> #25
packagingOptions {
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/LICENSE.md'
}
to my build.gradle file though. Not sure if that was a unique problem for me however.
jo...@gmail.com <jo...@gmail.com> #26
use this in build.gradle:
implementation 'com.sun.mail:android-mail:1.6.6'
implementation 'com.sun.mail:android-activation:1.6.6'
and then add the following packaging options:
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/LICENSE.md'
ds...@sigmasolve.com <ds...@sigmasolve.com> #27
[Error: IOException while sending message]
Description
For many years I have used the Java mail dependencies to allow users in my app to send bulk emails from their gmail account. (Used by teachers to email students in a class). Recently, when I bumped my Target SDK to 30, the app now crashes when sending email. Here are the details.
Module dependencies
implementation 'com.sun.mail:android-mail:1.6.5'
implementation 'com.sun.mail:android-activation:1.6.5'
The crash is occurring below at the email.writeTo(baos) line below.
public static com.google.api.services.gmail.model.Message createMessageWithEmail(MimeMessage email)
throws MessagingException, IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
email.writeTo(baos);
String encodedEmail = new String(Base64.encodeBase64(baos.toByteArray()));
Message message = new Message();
message.setRaw(encodedEmail);
return message;
}
The following function sendMessage is called.
sendMessage(gmailService, selectedBulkEmailGmailAccount, createEmailWithAttachment(names[i][3], selectedBulkEmailGmailAccount, autoSubject, autoMessage, pdfName));
public static void sendMessage(Gmail service, String userId, MimeMessage email)
throws MessagingException, IOException {
Message message = createMessageWithEmail(email);
service.users().messages().send(userId, message).execute();
}
If I change the target SDK back to 29 or lower this all works fine. So it seems something about SDK 30 is causing the issue, but I can't find any documentation regarding this.
Here is the crash report info from Logcat
Caused by: java.lang.VerifyError: Rejecting class com.sun.mail.handlers.text_plain that attempts to sub-type erroneous class com.sun.mail.handlers.handler_base (declaration of 'com.sun.mail.handlers.text_plain' appears in /data/app/~~Shg29kugxzsx264_5llofg==/com.apps.ips.teachernotes3-KSLJYGOpua3Ha3D8mBp1lg==/base.apk)
at java.lang.Class.newInstance(Native Method)
at javax.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:601)
at javax.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:555)
at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:597)
at javax.activation.DataHandler.writeTo(DataHandler.java:299)
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:316)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1551)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1148)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:498)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1509)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2238)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2198)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1877)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1854)
Please also run "adb bugreport" and archive the output.
To avoid leaking private information, please share screenshots and bugreports only in Google Drive. Share files with android-bugreport@google.com and include only Google drive links in your bug. Bug report attachments should not be included directly in issue reports.