我试图在我的应用程序中使用JavaMail Android端口,但是当我尝试发送任何内容时,我的应用程序崩溃了。我已按照指南here创建了Mail
课程。然后在我的MainActivity
我添加了
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Mail m = new Mail("mailtosendfrom", "mypassword");
new SendMailTask().execute(m);
}
private class SendMailTask extends AsyncTask<Mail, Void, Void> {
@Override
protected Void doInBackground(Mail... mail) {
Mail m = mail[0];
String[] toArr = {"mailtosendto"};
m.setTo(toArr);
m.setFrom("mailtosendfrom");
m.setSubject("This is an email sent using my Mail JavaMail wrapper from an Android device.");
m.setBody("Email body.");
try {
m.send();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mypackage" >
<uses-permission android:name="android.permission.INTERNET" />
<application ...>
...
</application>
</manifest>
现在,当我启动应用程序时,它会立即崩溃,并在logcat中显示以下消息:
04-19 18:37:58.540 4547-4547/? D/AndroidRuntime﹕ >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
04-19 18:37:58.540 4547-4547/? D/AndroidRuntime﹕ CheckJNI is ON
04-19 18:37:58.570 4547-4547/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
04-19 18:37:58.570 4547-4547/? E/android.os.Debug﹕ failed to load memtrack module: -2
04-19 18:37:58.590 4547-4547/? D/AndroidRuntime﹕ Calling main entry com.android.commands.am.Am
--------- beginning of system
04-19 18:37:58.590 1313-1823/system_process I/ActivityManager﹕ Force stopping com.oskar.ratingapp appid=10046 user=0: from pid 4547
04-19 18:37:58.600 4547-4547/? D/AndroidRuntime﹕ Shutting down VM
04-19 18:37:58.600 4547-4550/? I/art﹕ Debugger is no longer active
04-19 18:37:58.600 4547-4556/? E/art﹕ Thread attaching while runtime is shutting down: Binder_1
04-19 18:37:58.600 4547-4556/? I/AndroidRuntime﹕ NOTE: attach of thread 'Binder_1' failed
04-19 18:37:58.990 4559-4559/? D/AndroidRuntime﹕ >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
04-19 18:37:58.990 4559-4559/? D/AndroidRuntime﹕ CheckJNI is ON
04-19 18:37:59.030 4559-4559/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
04-19 18:37:59.030 4559-4559/? E/android.os.Debug﹕ failed to load memtrack module: -2
04-19 18:37:59.050 4559-4559/? D/AndroidRuntime﹕ Calling main entry com.android.commands.am.Am
04-19 18:37:59.060 1313-1804/system_process I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.oskar.ratingapp/.MainActivity} from uid 0 on display 0
04-19 18:37:59.070 4559-4559/? D/AndroidRuntime﹕ Shutting down VM
04-19 18:37:59.080 1313-1330/system_process I/ActivityManager﹕ Start proc com.oskar.ratingapp for activity com.oskar.ratingapp/.MainActivity: pid=4569 uid=10046 gids={50046, 9997, 3003} abi=x86_64
04-19 18:37:59.080 4559-4561/? I/art﹕ Debugger is no longer active
04-19 18:37:59.080 4569-4569/? E/libprocessgroup﹕ failed to make and chown /acct/uid_10046: Read-only file system
04-19 18:37:59.080 4569-4569/? W/Zygote﹕ createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
04-19 18:37:59.080 4569-4569/? I/art﹕ Not late-enabling -Xcheck:jni (already on)
04-19 18:37:59.330 4569-4585/? D/OpenGLRenderer﹕ Render dirty regions requested: true
04-19 18:37:59.350 4569-4569/? D/﹕ HostConnection::get() New Host Connection established 0x7fb32fc8f280, tid 4569
04-19 18:37:59.370 4569-4569/? D/Atlas﹕ Validating map...
04-19 18:37:59.430 4569-4585/? D/﹕ HostConnection::get() New Host Connection established 0x7fb32fc8ff40, tid 4585
04-19 18:37:59.440 4569-4585/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
04-19 18:37:59.460 4569-4585/? D/OpenGLRenderer﹕ Enabling debug mode 0
04-19 18:37:59.480 4569-4585/? W/EGL_emulation﹕ eglSurfaceAttrib not implemented
04-19 18:37:59.480 4569-4585/? W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb32fc8ef00, error=EGL_SUCCESS
--------- beginning of crash
04-19 18:37:59.610 4569-4584/? A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x750000013f in tid 4584 (AsyncTask #1)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-19 18:37:59.730 957-957/? I/DEBUG﹕ Build fingerprint: 'generic_x86_64/sdk_phone_x86_64/generic_x86_64:5.0/LRX09D/1504858:eng/test-keys'
04-19 18:37:59.730 957-957/? I/DEBUG﹕ Revision: '0'
04-19 18:37:59.730 957-957/? I/DEBUG﹕ ABI: 'x86_64'
04-19 18:37:59.730 957-957/? I/DEBUG﹕ pid: 4569, tid: 4584, name: AsyncTask #1 >>> com.oskar.ratingapp <<<
04-19 18:37:59.730 957-957/? I/DEBUG﹕ signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x750000013f
04-19 18:37:59.730 957-957/? I/DEBUG﹕ rax 0000000000000000 rbx 000000750000008f rcx 0000000000000081 rdx 0000000000000001
04-19 18:37:59.730 957-957/? I/DEBUG﹕ rsi 000000000000001e rdi 00007fb33a7a72b0
04-19 18:37:59.730 957-957/? I/DEBUG﹕ r8 000000000000014a r9 0000000000000000 r10 00007fb33e64fe2c r11 00007fb3410b12c0
04-19 18:37:59.730 957-957/? I/DEBUG﹕ r12 00007fb32fc91380 r13 0000000000000001 r14 00007fb32fccf268 r15 00007fb32fccf380
04-19 18:37:59.730 957-957/? I/DEBUG﹕ cs 0000000000000033 ss 000000000000002b
04-19 18:37:59.730 957-957/? I/DEBUG﹕ rip 00007fb3411144d6 rbp 0000000000000000 rsp 00007fb32fbfeb30 eflags 0000000000010202
04-19 18:37:59.730 957-957/? I/DEBUG﹕ backtrace:
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #00 pc 00000000000e34d6 /system/lib64/libcrypto.so (ENGINE_init+38)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #01 pc 00000000000eb435 /system/lib64/libcrypto.so (EVP_MD_CTX_copy_ex+37)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #02 pc 00000000000f8582 /system/lib64/libcrypto.so (HMAC_CTX_copy+66)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #03 pc 00000000000f7e32 /system/lib64/libcrypto.so
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #04 pc 00000000000f698a /system/lib64/libcrypto.so (EVP_PKEY_CTX_dup+234)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #05 pc 00000000000eb52b /system/lib64/libcrypto.so (EVP_MD_CTX_copy_ex+283)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #06 pc 000000000004a9b3 /system/lib64/libssl.so (tls1_mac+195)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #07 pc 0000000000032456 /system/lib64/libssl.so
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #08 pc 000000000003207e /system/lib64/libssl.so (ssl3_write_bytes+302)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #09 pc 00000000000261d0 /system/lib64/libssl.so (ssl3_do_write+32)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #10 pc 0000000000028ef1 /system/lib64/libssl.so (ssl3_connect+2353)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #11 pc 00000000000207d7 /system/lib64/libssl.so (ssl23_connect+3463)
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #12 pc 00000000000186a2 /system/lib64/libjavacrypto.so
04-19 18:37:59.730 957-957/? I/DEBUG﹕ #13 pc 0000000000409ef1 /data/dalvik-cache/x86_64/system@framework@boot.oat
04-19 18:37:59.800 957-957/? I/DEBUG﹕ Tombstone written to: /data/tombstones/tombstone_01
04-19 18:37:59.840 1313-1399/system_process W/InputDispatcher﹕ channel '27028e74 com.oskar.ratingapp/com.oskar.ratingapp.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
04-19 18:37:59.840 1313-1399/system_process E/InputDispatcher﹕ channel '27028e74 com.oskar.ratingapp/com.oskar.ratingapp.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
04-19 18:37:59.840 963-963/? I/Zygote﹕ Process 4569 exited due to signal (11)
04-19 18:37:59.940 1313-4593/system_process W/ActivityManager﹕ Force finishing activity com.oskar.ratingapp/.MainActivity
04-19 18:37:59.950 1313-1822/system_process I/WindowState﹕ WIN DEATH: Window{27028e74 u0 com.oskar.ratingapp/com.oskar.ratingapp.MainActivity}
04-19 18:37:59.950 1313-1822/system_process W/InputDispatcher﹕ Attempted to unregister already unregistered input channel '27028e74 com.oskar.ratingapp/com.oskar.ratingapp.MainActivity (server)'
04-19 18:37:59.950 1313-4593/system_process E/ActivityManager﹕ Invalid thumbnail dimensions: 360x360
04-19 18:37:59.950 1313-4593/system_process W/ActivityManager﹕ Exception thrown during pause
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:479)
at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:701)
at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:852)
at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2754)
at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2611)
at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2448)
at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:11507)
at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11404)
at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12083)
at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:11599)
at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
04-19 18:37:59.950 946-946/? E/lowmemorykiller﹕ Error opening /proc/4569/oom_score_adj; errno=2
04-19 18:37:59.960 1313-1329/system_process I/ActivityManager﹕ Process com.oskar.ratingapp (pid 4569) has died
04-19 18:38:00.000 1313-2329/system_process I/OpenGLRenderer﹕ Initialized EGL, version 1.4
04-19 18:38:00.010 1903-1968/com.android.launcher W/EGL_emulation﹕ eglSurfaceAttrib not implemented
04-19 18:38:00.010 1903-1968/com.android.launcher W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb32dde2980, error=EGL_SUCCESS
04-19 18:38:00.010 1313-2329/system_process W/EGL_emulation﹕ eglSurfaceAttrib not implemented
04-19 18:38:00.010 1313-2329/system_process W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb328cf1780, error=EGL_SUCCESS
04-19 18:38:03.090 1313-1426/system_process D/TaskPersister﹕ removeObsoleteFile: deleting file=44_task.xml
04-19 18:38:03.200 1313-1414/system_process W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
04-19 18:38:03.220 1313-1463/system_process W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@12273a0d attribute=null, token = android.os.BinderProxy@133a0350
04-19 18:38:03.740 1903-1968/com.android.launcher W/OpenGLRenderer﹕ Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
答案 0 :(得分:0)
在黑暗中完成拍摄。然而,这对我有用。
试试这个
class MyClass {
public static void main(String[] args) {
ClassA a = new ClassSubA(); // create an instance of ClassSubA
InterfaceB b = a.methodA(); // will return an instance of ClassSubB
b.methodB(); // will call methodB of ClassSubB
}
}
我之前遇到过AsyncTasks的问题。希望它有所帮助!
答案 1 :(得分:0)
代码不是问题,模拟器是。
我只是在设备而不是模拟器上尝试过它,它可以完美运行。