[Nexus 6 Q&A, Help & Troubleshooting] codecaine21:
So, I have written an app that emails a file on every boot iteration. I flashed a new ROM and now it isnt working. I reboot and run a logcat on boot and see that the logcat and or gmail is complaining about no e-mail application being installed.

The error seems to be:

05-06 11:53:52.813 2514 2624 I Gmail : getAccountsCursor
05-06 11:53:52.814 2514 2625 D ActivityThread: Loading provider com.google.android.gmail.provider;com.android.mail.notifier;com.google.android.gm.email.provider;com.google.android.gm.email.notifier: com.android.email.provider.EmailProvider
05-06 11:53:53.282 935 2233 W ActivityManager: Unable to start service Intent { cmp=me.bluemail.mail/com.android.emaileas.service.AttachmentService } U=0: not found
05-06 11:53:53.314 935 2081 W ActivityManager: Unable to start service Intent { cmp=me.bluemail.mail/com.android.emaileas.service.AttachmentService } U=0: not found
05-06 11:53:53.452 2514 2685 I Gmail : No Email application installed
05-06 11:53:53.452 2514 2685 I EmailMigration: No data to migrate
05-06 11:53:53.452 2514 2685 W EmailMigration: No Exchange migration, not the right Email provider version

I do in fact have gmail installed and i went as far as installing a 3rd party email client.

The code I have is an smtp client written by someone else that has been integrated with my code. Like i stated before, everything worked before the flash. I actually figured the issue out last time but cant remember the solution I implemented.

I came from DU 5.1 and moved to DU 6.0. I flashed 4 different ROMs in hopes that it was the ROM but this was not the case.

I am using a rooted Nexus 6 and developing on Linux with no IDE.

The SMTP Client:

GmailSender.java

package com.keysender;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayInputStream;

import android.util.Log;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import java.util.Properties;
import java.security.Security;
import javax.activation.DataSource;
import javax.activation.DataHandler;
import javax.mail.internet.MimeMessage;
import javax.mail.PasswordAuthentication;
import javax.mail.internet.InternetAddress;

public class GmailSender extends javax.mail.Authenticator {
private String mailhost = "smtp.gmail.com";
private String user;
private String password;
private Session session;

static {
Security.addProvider(new com.keysender.JSSEProvider());
}

public GmailSender(String user, String password) {
this.user = user;
this.password = password;
try {
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");

session = Session.getDefaultInstance(props, this);
}
catch(Exception e) {
e.printStackTrace();
Log.d("ERROR ", e.getMessage(), e);
}
}

protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}

public synchronized void sendMail(String subject, String body, String sender, String recipients) throws Exception {
try{
MimeMessage message = new MimeMessage(session);
DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));
//DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "message/rfc822"));
message.setSender(new InternetAddress(sender));
message.setSubject(subject);
message.setDataHandler(handler);
if (recipients.indexOf(',') > 0)
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));
else
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));
Transport.send(message);
}catch(Exception e){
e.printStackTrace();
}
}

public class ByteArrayDataSource implements DataSource {
private byte[] data;
private String type;

public ByteArrayDataSource(byte[] data, String type) {
super();
this.data = data;
this.type = type;
}

public ByteArrayDataSource(byte[] data) {
super();
this.data = data;
}

public void setType(String type) {
this.type = type;
}

public String getContentType() {
if (type == null)
return "application/octet-stream";
else
return type;
}

public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(data);
}

public String getName() {
return "ByteArrayDataSource";
}

public OutputStream getOutputStream() throws IOException {
throw new IOException("Not Supported");
}
}
}

JSSEProvider.java

package com.keysender;

import java.security.AccessController;
import java.security.Provider;

public final class JSSEProvider extends Provider {

public JSSEProvider() {
super("HarmonyJSSE", 1.0, "Harmony JSSE Provider");
AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
public Void run() {
put("SSLContext.TLS",
"org.apache.harmony.xnet.provider.jsse.SSLContextImpl");
put("Alg.Alias.SSLContext.TLSv1", "TLS");
put("KeyManagerFactory.X509",
"org.apache.harmony.xnet.provider.jsse.KeyManagerFactoryImpl");
put("TrustManagerFactory.X509",
"org.apache.harmony.xnet.provider.jsse.TrustManagerFactoryImpl");
return null;
}
});
}
}

Relevant code snippet from my email method inside of my BootService class

try {
GmailSender sender = new GmailSender("email@gmail.com", "password");
sender.sendMail("keysender", text.toString(), "blah1@gmail.com", "blah2@gmail.com");
deleteFile();
}
catch(Exception e) {
e.printStackTrace();
Log.e("Mail could not be sent.", e.getMessage(), e);
}