0

Without using the default mail application and with a click of a single button i would like to send the mail from my app.

i followed this link :

Sending Email in Android using JavaMail API without using the default/built-in app

added permission to the mainfest file, still its not working. kindly help.

The app force closes when i open it on my device.

My logcat file reads:

08-23 15:10:26.126: ERROR/AndroidRuntime(18094): FATAL EXCEPTION: main
08-23 15:10:26.126: ERROR/AndroidRuntime(18094): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.mailsend/org.mailsend.MailSenderActivity.java}: java.lang.ClassNotFoundException: org.mailsend.MailSenderActivity.java in loader dalvik.system.PathClassLoader[/mnt/asec/org.mailsend-2/pkg.apk]
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1743)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.app.ActivityThread.access$1500(ActivityThread.java:132)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.os.Looper.loop(Looper.java:143)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.app.ActivityThread.main(ActivityThread.java:4277)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at java.lang.reflect.Method.invokeNative(Native Method)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at java.lang.reflect.Method.invoke(Method.java:507)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at dalvik.system.NativeStart.main(Native Method)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094): Caused by: java.lang.ClassNotFoundException: org.mailsend.MailSenderActivity.java in loader dalvik.system.PathClassLoader[/mnt/asec/org.mailsend-2/pkg.apk]
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735)
08-23 15:10:26.126: ERROR/AndroidRuntime(18094):     ... 11 more

The code I used is same as the one in Sending Email in Android using JavaMail API without using the default/built-in app

This is my mainfest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="org.mailsend"
  android:versionCode="1"
  android:versionName="1.0"
  android:installLocation="preferExternal" >
 <uses-permission android:name="android.permission.INTERNET"></uses-permission>


<application android:icon="@drawable/icon" android:label="@string/app_name"       android:debuggable="true">
    <activity android:name=".MailSenderActivity.java"
              android:label="@string/app_name">
              <activity android:name=".GMailSender"></activity>
               <activity android:name=".MailSenderActivity"></activity>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>


</application>

Community
  • 1
  • 1
user838522
  • 3,821
  • 3
  • 23
  • 24
  • Can android do **that**? Could it send as you, or just decide to send random stuff from your memory card back to home base? Sounds vaguely scary. – Paul Aug 23 '11 at 09:10
  • 2
    Please be more specific, post the logcat of your errors, post the code that's not working. Help people help you – Egor Aug 23 '11 at 09:12
  • @user838522 what is the Error in your LogCat? – Blundell Aug 23 '11 at 09:12
  • sorry since my rep is less on SO, I'm unable to paste images, so I've pasted the logcat as it is. – user838522 Aug 23 '11 at 09:51
  • @Paul: Of course Android can do that. Give it internet permissions and SD card permissions and it'll be able to open a connection to a webserver (any type including file or mail), and systematically upload your entire sd card. Though it'll need to be run at least once allowing it to start a service so that it wont be shut down by Android... – Kurru Aug 23 '11 at 09:59

2 Answers2

0
  1. Check the package name in GMailSender.java file

      static {   
              Security.addProvider(new PACKED-NAME.JSSEProvider());   
             }  
    
  2. add code in JSSEProvider file

    public final class JSSEProvider extends Provider {
    
        private static final long serialVersionUID = 1L;   ---> this code is add
    
0

You are missing the org.mailsend.MailSenderActivity class in your APK file, so it cannot be started. Either add this class to your APK file or modify the manifest to not include it (and do not try to start it).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • that doesn't seem to be the problem and org.mailsend.MailSenderActivity is present in the class file. – user838522 Aug 23 '11 at 10:21
  • @user838522: It is the problem that is reported by your stack trace. – CommonsWare Aug 23 '11 at 10:22
  • I have one package called org.mailsend which holds 2 classes called GmailSender.java and MailSenderActivity.java and another package called com.provider which holds JSSEProvider.java; but why wouldn't it automatically add the packages into my apk file? – user838522 Aug 23 '11 at 10:29
  • @user838522: I have no means of answering that question, sorry. – CommonsWare Aug 23 '11 at 10:40