0

ユーザーにサインアップ成功メールを送信する必要がある Android アプリ登録フォームがありますが、送信ボタンの onClick でそのクラスを呼び出すと、次のエラーが発生します。

FATAL EXCEPTION: AsyncTask #1
 java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:200)
    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
    at java.lang.Thread.run(Thread.java:1019)
Caused by: java.lang.NoClassDefFoundError: net.asdqwe.utilities.Mail
    at net.asdqwe.utilities.EmailSender.sendEmail(EmailSender.java:8)
    at net.asdqwe.activities.Signup$sendVerificationEmail.doInBackground(Signup.java:308)
    at net.asdqwe.activities.Signup$sendVerificationEmail.doInBackground(Signup.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
    ... 4 more

これを呼び出すコードは次のとおりです。

public class Signup extends Activity implements OnClickListener,  {

@Override
    public void onClick(View arg0) {
    //some irrelevant code here

            Intent signupSuccessAvatarUpload = new Intent(getApplicationContext(), SignupSuccessAvatarUpload.class);
            signupSuccessAvatarUpload.putExtra("userEmailID", userEmail);
            try {
                new sendVerificationEmail().execute();
            } catch (Exception e) {}
            addNewContact();
            startActivityForResult(signupSuccessAvatarUpload, 1);
            //finish();
    }
class sendVerificationEmail extends AsyncTask<String, Void, String> {

        @Override
        protected String doInBackground(String... params) {
            try {
                emailSender.sendEmail(userEmail, configurationz.EMAIL_OFFICIAL_ADDRESS, configurationz.EMAIL_SUCCESSFUL_SIGNUP_SUBJECT, configurationz.EMAIL_SUCCESSFUL_SIGNUP_BODY(userName), null);
            } catch (Exception e) {}
            return null;
        }

    }
}

メール送信者クラスは次のとおりです。

package net.asdqwe.utilities;

import net.asdqwe.utilities.Mail;

public class EmailSender {
    public boolean sendEmail(String to, String from, String subject, String message, String[] attachements) throws Exception {
        Mail mail = new Mail();
        //code here
}

同じパッケージに Mail クラスがあります。

public class Mail extends javax.mail.Authenticator {
//lots of code here

public Mail() {
    host = "smtp.googlemail.com"; // default smtp server
    port = "465"; // default smtp port
    sport = "465"; // default socketfactory port

    user = ""; // username
    password = ""; // password
    from = ""; // email sent from
    subject = ""; // email subject
    body = ""; // email body

    _debuggable = false; // debug mode on or off - default off
    _auth = true; // smtp authentication - default on

    multipart = new MimeMultipart();

    // There is something wrong with MailCap, javamail can not find a
    // handler for the multipart/mixed part, so this bit needs to be added.
    MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
    mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
    mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
    mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
    mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
    mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
    CommandMap.setDefaultCommandMap(mc);
}

public Mail(String user, String pass) {
    this();

    this.user = user;
    password = pass;
}
}
4

1 に答える 1