I have NullPointException in my code, and this is the reason why my app is crashing...
I'm new in Android development, so can you please help me to avoid this Null exception?
here is some code, where i think is this error:
#Override
public void onClick(View v) {
btn_skip = (Button) findViewById(R.id.btn_skip);
// get data
String email_txt = email.getEditableText().toString();
String confirme_email = confirm_email.getEditableText().toString();
//get IMEI
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
imei = telephonyManager.getDeviceId();
if (v == btn_skip)
{
sendPostRequest(null, null, imei);
}
//if email is not valid then show errors
else if (!checkEmail(email.getText().toString()) && v == btn_get_access)
{
email_error.setVisibility(View.VISIBLE);
email.requestFocus();
//Toast.makeText(getBaseContext(), "lkdjfgkdjg", Toast.LENGTH_LONG).show();
}
//else if (!confirme_email.equals(email_txt) && v == btn_get_access)
else if (!email_txt.equals(confirme_email))
{
email_confirm_error.setVisibility(View.VISIBLE);
confirm_email.requestFocus();
}
else
{
email_error.setVisibility(View.GONE);
email_confirm_error.setVisibility(View.GONE);
sendPostRequest(email_txt, confirme_email, imei);
}
}
so how i get this error:
in my app i have 2 activities, and i can switch them by buttons, first button send some data which i get from user on the server (all inputs are filled with data), with the second button i can skip the input filling and go to the second screen(all inputs are empty);
from the 2nd screen i can go back to the first screen without any data(and when i press this back button, i have this null exception).
Please help me with this error, because i can't imagine how to avoid it...
UPD LOGCAT
03-05 10:01:07.214: W/ActivityThread(12011): Application com.vladimir.expert_suise is waiting for the debugger on port 8100...
03-05 10:01:07.224: I/System.out(12011): Sending WAIT chunk
03-05 10:01:07.224: I/dalvikvm(12011): Debugger is active
03-05 10:01:07.424: I/System.out(12011): Debugger has connected
03-05 10:01:07.424: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:07.624: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:07.814: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:08.014: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:08.215: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:08.415: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:08.615: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:08.815: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:09.015: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:09.226: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:09.426: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:09.626: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:09.826: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:10.026: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:10.226: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:10.427: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:10.627: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:10.827: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:11.027: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:11.227: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:11.428: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:11.628: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:11.828: I/System.out(12011): waiting for debugger to settle...
03-05 10:01:12.028: I/System.out(12011): debugger has settled (1463)
03-05 10:01:13.620: D/libEGL(12011): loaded /system/lib/egl/libGLES_android.so
03-05 10:01:13.800: D/libEGL(12011): loaded /system/lib/egl/libEGL_adreno200.so
03-05 10:01:14.080: D/libEGL(12011): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
03-05 10:01:14.080: D/libEGL(12011): loaded /system/lib/egl/libGLESv2_adreno200.so
03-05 10:01:14.401: I/Adreno200-EGLSUB(12011): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:14.561: D/memalloc(12011): ashmem: Mapped buffer base:0x520a0000 size:1536000 fd:61
03-05 10:01:14.591: D/OpenGLRenderer(12011): Enabling debug mode 0
03-05 10:01:15.141: D/OpenGLRenderer(12011): has fontRender patch
03-05 10:01:15.171: D/OpenGLRenderer(12011): has fontRender patch
03-05 10:01:15.211: D/OpenGLRenderer(12011): has fontRender patch
03-05 10:01:15.281: D/memalloc(12011): ashmem: Mapped buffer base:0x5251a000 size:1536000 fd:64
03-05 10:01:15.962: D/memalloc(12011): ashmem: Mapped buffer base:0x52691000 size:1536000 fd:67
03-05 10:01:19.996: I/Adreno200-EGLSUB(12011): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:20.006: D/memalloc(12011): ashmem: Mapped buffer base:0x52b08000 size:1536000 fd:76
03-05 10:01:20.316: D/memalloc(12011): ashmem: Mapped buffer base:0x52cff000 size:1536000 fd:79
03-05 10:01:20.647: I/Adreno200-EGLSUB(12011): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:20.657: D/memalloc(12011): ashmem: Mapped buffer base:0x52f76000 size:1536000 fd:82
03-05 10:01:20.797: D/memalloc(12011): ashmem: Mapped buffer base:0x530ed000 size:1536000 fd:88
03-05 10:01:20.957: D/memalloc(12011): ashmem: Mapped buffer base:0x53264000 size:1536000 fd:91
03-05 10:01:21.157: D/memalloc(12011): ashmem: Mapped buffer base:0x533db000 size:1536000 fd:94
03-05 10:01:21.177: D/OpenGLRenderer(12011): Flushing caches (mode 0)
03-05 10:01:21.207: D/OpenGLRenderer(12011): Flushing caches (mode 0)
03-05 10:01:22.999: I/Adreno200-EGLSUB(12011): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:23.019: D/memalloc(12011): ashmem: Mapped buffer base:0x5251a000 size:1536000 fd:63
03-05 10:01:23.309: D/memalloc(12011): ashmem: Mapped buffer base:0x52691000 size:1536000 fd:69
03-05 10:01:23.419: I/Adreno200-EGLSUB(12011): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:23.429: D/memalloc(12011): ashmem: Mapped buffer base:0x52a08000 size:1536000 fd:79
03-05 10:01:23.610: D/memalloc(12011): ashmem: Mapped buffer base:0x52cff000 size:1536000 fd:88
03-05 10:01:23.660: D/memalloc(12011): ashmem: Mapped buffer base:0x530ed000 size:1536000 fd:97
03-05 10:01:23.830: D/memalloc(12011): ashmem: Mapped buffer base:0x53552000 size:1536000 fd:100
03-05 10:01:23.850: D/OpenGLRenderer(12011): Flushing caches (mode 0)
03-05 10:01:23.870: D/OpenGLRenderer(12011): Flushing caches (mode 0)
03-05 10:01:25.291: I/Adreno200-EGLSUB(12011): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:25.301: D/memalloc(12011): ashmem: Mapped buffer base:0x5261a000 size:1536000 fd:63
03-05 10:01:25.451: D/memalloc(12011): ashmem: Mapped buffer base:0x52e76000 size:1536000 fd:82
03-05 10:01:25.481: D/OpenGLRenderer(12011): Flushing caches (mode 0)
03-05 10:01:25.882: D/memalloc(12011): ashmem: Mapped buffer base:0x52a08000 size:1536000 fd:79
03-05 10:01:27.603: D/AndroidRuntime(12011): Shutting down VM
03-05 10:01:27.603: W/dalvikvm(12011): threadid=1: thread exiting with uncaught exception (group=0x40ad9228)
03-05 10:01:27.633: E/AndroidRuntime(12011): FATAL EXCEPTION: main
03-05 10:01:27.633: E/AndroidRuntime(12011): java.lang.NullPointerException
03-05 10:01:27.633: E/AndroidRuntime(12011): at com.vladimir.expert_suise.FirstScreen.onClick(FirstScreen.java:174)
03-05 10:01:27.633: E/AndroidRuntime(12011): at android.view.View.performClick(View.java:3549)
03-05 10:01:27.633: E/AndroidRuntime(12011): at android.view.View$PerformClick.run(View.java:14400)
03-05 10:01:27.633: E/AndroidRuntime(12011): at android.os.Handler.handleCallback(Handler.java:605)
03-05 10:01:27.633: E/AndroidRuntime(12011): at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 10:01:27.633: E/AndroidRuntime(12011): at android.os.Looper.loop(Looper.java:154)
03-05 10:01:27.633: E/AndroidRuntime(12011): at android.app.ActivityThread.main(ActivityThread.java:4945)
03-05 10:01:27.633: E/AndroidRuntime(12011): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 10:01:27.633: E/AndroidRuntime(12011): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 10:01:27.633: E/AndroidRuntime(12011): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-05 10:01:27.633: E/AndroidRuntime(12011): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-05 10:01:27.633: E/AndroidRuntime(12011): at dalvik.system.NativeStart.main(Native Method)
03-05 10:01:30.747: D/Process(12011): killProcess, pid=12011
03-05 10:01:30.757: D/Process(12011): dalvik.system.VMStack.getThreadStackTrace(Native Method)
03-05 10:01:30.757: D/Process(12011): java.lang.Thread.getStackTrace(Thread.java:599)
03-05 10:01:30.757: D/Process(12011): android.os.Process.killProcess(Process.java:788)
03-05 10:01:30.757: D/Process(12011): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:104)
03-05 10:01:30.757: D/Process(12011): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-05 10:01:30.757: D/Process(12011): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-05 10:01:30.757: D/Process(12011): dalvik.system.NativeStart.main(Native Method)
03-05 10:01:30.757: I/Process(12011): Sending signal. PID: 12011 SIG: 9
03-05 10:01:31.307: D/libEGL(12216): loaded /system/lib/egl/libGLES_android.so
03-05 10:01:31.307: D/libEGL(12216): loaded /system/lib/egl/libEGL_adreno200.so
03-05 10:01:31.307: D/libEGL(12216): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
03-05 10:01:31.317: D/libEGL(12216): loaded /system/lib/egl/libGLESv2_adreno200.so
03-05 10:01:31.337: I/Adreno200-EGLSUB(12216): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:31.357: D/memalloc(12216): ashmem: Mapped buffer base:0x51fa0000 size:1536000 fd:61
03-05 10:01:31.367: D/OpenGLRenderer(12216): Enabling debug mode 0
03-05 10:01:31.417: D/OpenGLRenderer(12216): has fontRender patch
03-05 10:01:31.437: D/OpenGLRenderer(12216): has fontRender patch
03-05 10:01:31.467: D/OpenGLRenderer(12216): has fontRender patch
03-05 10:01:31.507: D/memalloc(12216): ashmem: Mapped buffer base:0x5241a000 size:1536000 fd:64
03-05 10:01:31.918: D/memalloc(12216): ashmem: Mapped buffer base:0x52691000 size:1536000 fd:67
03-05 10:01:47.313: D/AndroidRuntime(12216): Shutting down VM
03-05 10:01:47.313: W/dalvikvm(12216): threadid=1: thread exiting with uncaught exception (group=0x40ad9228)
03-05 10:01:47.313: E/AndroidRuntime(12216): FATAL EXCEPTION: main
03-05 10:01:47.313: E/AndroidRuntime(12216): java.lang.NullPointerException
03-05 10:01:47.313: E/AndroidRuntime(12216): at com.vladimir.expert_suise.FirstScreen.onClick(FirstScreen.java:174)
03-05 10:01:47.313: E/AndroidRuntime(12216): at android.view.View.performClick(View.java:3549)
03-05 10:01:47.313: E/AndroidRuntime(12216): at android.view.View$PerformClick.run(View.java:14400)
03-05 10:01:47.313: E/AndroidRuntime(12216): at android.os.Handler.handleCallback(Handler.java:605)
03-05 10:01:47.313: E/AndroidRuntime(12216): at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 10:01:47.313: E/AndroidRuntime(12216): at android.os.Looper.loop(Looper.java:154)
03-05 10:01:47.313: E/AndroidRuntime(12216): at android.app.ActivityThread.main(ActivityThread.java:4945)
03-05 10:01:47.313: E/AndroidRuntime(12216): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 10:01:47.313: E/AndroidRuntime(12216): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 10:01:47.313: E/AndroidRuntime(12216): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-05 10:01:47.313: E/AndroidRuntime(12216): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-05 10:01:47.313: E/AndroidRuntime(12216): at dalvik.system.NativeStart.main(Native Method)
03-05 10:01:49.064: D/Process(12216): killProcess, pid=12216
03-05 10:01:49.064: D/Process(12216): dalvik.system.VMStack.getThreadStackTrace(Native Method)
03-05 10:01:49.064: D/Process(12216): java.lang.Thread.getStackTrace(Thread.java:599)
03-05 10:01:49.064: D/Process(12216): android.os.Process.killProcess(Process.java:788)
03-05 10:01:49.064: D/Process(12216): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:104)
03-05 10:01:49.064: D/Process(12216): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-05 10:01:49.064: D/Process(12216): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-05 10:01:49.064: D/Process(12216): dalvik.system.NativeStart.main(Native Method)
03-05 10:01:49.064: I/Process(12216): Sending signal. PID: 12216 SIG: 9
03-05 10:01:49.545: D/libEGL(12233): loaded /system/lib/egl/libGLES_android.so
03-05 10:01:49.555: D/libEGL(12233): loaded /system/lib/egl/libEGL_adreno200.so
03-05 10:01:49.555: D/libEGL(12233): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
03-05 10:01:49.555: D/libEGL(12233): loaded /system/lib/egl/libGLESv2_adreno200.so
03-05 10:01:49.575: I/Adreno200-EGLSUB(12233): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:01:49.585: D/memalloc(12233): ashmem: Mapped buffer base:0x51fb9000 size:1536000 fd:62
03-05 10:01:49.585: D/OpenGLRenderer(12233): Enabling debug mode 0
03-05 10:01:49.645: D/OpenGLRenderer(12233): has fontRender patch
03-05 10:01:49.665: D/OpenGLRenderer(12233): has fontRender patch
03-05 10:01:49.685: D/OpenGLRenderer(12233): has fontRender patch
03-05 10:01:49.755: D/memalloc(12233): ashmem: Mapped buffer base:0x52466000 size:1536000 fd:65
03-05 10:01:50.135: D/memalloc(12233): ashmem: Mapped buffer base:0x526dd000 size:1536000 fd:68
03-05 10:01:51.347: D/OpenGLRenderer(12233): Flushing caches (mode 0)
03-05 10:01:51.447: W/IInputConnectionWrapper(12233): showStatusIcon on inactive InputConnection
03-05 10:01:51.447: W/IInputConnectionWrapper(12233): InputConnection = com.android.internal.widget.EditableInputConnection#40dd02e8, active client = false
03-05 10:01:51.647: D/OpenGLRenderer(12233): Flushing caches (mode 1)
03-05 10:02:00.155: D/OpenGLRenderer(12233): Flushing caches (mode 1)
03-05 10:02:08.814: D/OpenGLRenderer(12233): Flushing caches (mode 1)
03-05 10:02:08.994: D/OpenGLRenderer(12233): Flushing caches (mode 2)
03-05 10:02:32.427: W/ActivityThread(12468): Application com.vladimir.expert_suise is waiting for the debugger on port 8100...
03-05 10:02:32.447: I/System.out(12468): Sending WAIT chunk
03-05 10:02:32.447: I/dalvikvm(12468): Debugger is active
03-05 10:02:32.647: I/System.out(12468): Debugger has connected
03-05 10:02:32.647: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:32.847: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:33.047: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:33.247: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:33.448: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:33.648: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:33.848: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:34.048: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:34.248: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:34.449: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:34.649: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:34.859: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:35.049: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:35.249: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:35.450: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:35.650: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:35.850: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:36.050: I/System.out(12468): waiting for debugger to settle...
03-05 10:02:36.250: I/System.out(12468): debugger has settled (1356)
03-05 10:02:37.502: D/libEGL(12468): loaded /system/lib/egl/libGLES_android.so
03-05 10:02:37.532: D/libEGL(12468): loaded /system/lib/egl/libEGL_adreno200.so
03-05 10:02:37.582: D/libEGL(12468): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
03-05 10:02:37.582: D/libEGL(12468): loaded /system/lib/egl/libGLESv2_adreno200.so
03-05 10:02:37.652: I/Adreno200-EGLSUB(12468): <ConfigWindowMatch:2078>: Format RGBA_8888.
03-05 10:02:37.692: D/memalloc(12468): ashmem: Mapped buffer base:0x520a0000 size:1536000 fd:61
03-05 10:02:37.702: D/OpenGLRenderer(12468): Enabling debug mode 0
03-05 10:02:37.902: D/OpenGLRenderer(12468): has fontRender patch
03-05 10:02:37.922: D/OpenGLRenderer(12468): has fontRender patch
03-05 10:02:37.952: D/OpenGLRenderer(12468): has fontRender patch
03-05 10:02:38.002: D/memalloc(12468): ashmem: Mapped buffer base:0x5251a000 size:1536000 fd:64
03-05 10:02:38.312: D/memalloc(12468): ashmem: Mapped buffer base:0x52691000 size:1536000 fd:67
03-05 10:03:07.731: D/dalvikvm(12468): Debugger has detached; object registry had 776 entries
03-05 10:03:07.731: D/AndroidRuntime(12468): Shutting down VM
03-05 10:03:07.731: W/dalvikvm(12468): threadid=1: thread exiting with uncaught exception (group=0x40ad9228)
03-05 10:03:07.731: E/AndroidRuntime(12468): FATAL EXCEPTION: main
03-05 10:03:07.731: E/AndroidRuntime(12468): java.lang.NullPointerException
03-05 10:03:07.731: E/AndroidRuntime(12468): at com.vladimir.expert_suise.FirstScreen.onClick(FirstScreen.java:174)
03-05 10:03:07.731: E/AndroidRuntime(12468): at android.view.View.performClick(View.java:3549)
03-05 10:03:07.731: E/AndroidRuntime(12468): at android.view.View$PerformClick.run(View.java:14400)
03-05 10:03:07.731: E/AndroidRuntime(12468): at android.os.Handler.handleCallback(Handler.java:605)
03-05 10:03:07.731: E/AndroidRuntime(12468): at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 10:03:07.731: E/AndroidRuntime(12468): at android.os.Looper.loop(Looper.java:154)
03-05 10:03:07.731: E/AndroidRuntime(12468): at android.app.ActivityThread.main(ActivityThread.java:4945)
03-05 10:03:07.731: E/AndroidRuntime(12468): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 10:03:07.731: E/AndroidRuntime(12468): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 10:03:07.731: E/AndroidRuntime(12468): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-05 10:03:07.731: E/AndroidRuntime(12468): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-05 10:03:07.731: E/AndroidRuntime(12468): at dalvik.system.NativeStart.main(Native Method)
try to remove Context like this:
TelephonyManager tManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String IMEI = tManager.getDeviceId();
taken from Using Telephony Manager in android to find IMEI number
Have you taken permission in manifest file??
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Related
I am using the code from this tutorial javapapers email app
I am getting these errors
03-05 01:33:25.649: E/SendMailTask(1926): null
03-05 01:33:25.649: E/SendMailTask(1926): javax.mail.AuthenticationFailedException
03-05 01:33:25.649: E/SendMailTask(1926): at javax.mail.Service.connect(Service.java:319)
03-05 01:33:25.649: E/SendMailTask(1926): at javax.mail.Service.connect(Service.java:169)
03-05 01:33:25.649: E/SendMailTask(1926): at com.javapapers.android.androidjavamail.GMail.sendEmail(GMail.java:82)
03-05 01:33:25.649: E/SendMailTask(1926): at com.javapapers.android.androidjavamail.SendMailTask.doInBackground(SendMailTask.java:39)
03-05 01:33:25.649: E/SendMailTask(1926): at android.os.AsyncTask$2.call(AsyncTask.java:288)
03-05 01:33:25.649: E/SendMailTask(1926): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-05 01:33:25.649: E/SendMailTask(1926): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
03-05 01:33:25.649: E/SendMailTask(1926): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-05 01:33:25.649: E/SendMailTask(1926): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-05 01:33:25.649: E/SendMailTask(1926): at java.lang.Thread.run(Thread.java:841)
and this
03-05 01:33:25.799: E/AndroidRuntime(1926): FATAL EXCEPTION: main
03-05 01:33:25.799: E/AndroidRuntime(1926): Process: com.javapapers.android.androidjavamail, PID: 1926
03-05 01:33:25.799: E/AndroidRuntime(1926): java.lang.NullPointerException
03-05 01:33:25.799: E/AndroidRuntime(1926): at com.javapapers.android.androidjavamail.SendMailTask.onProgressUpdate(SendMailTask.java:51)
03-05 01:33:25.799: E/AndroidRuntime(1926): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:648)
03-05 01:33:25.799: E/AndroidRuntime(1926): at android.os.Handler.dispatchMessage(Handler.java:102)
03-05 01:33:25.799: E/AndroidRuntime(1926): at android.os.Looper.loop(Looper.java:136)
03-05 01:33:25.799: E/AndroidRuntime(1926): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-05 01:33:25.799: E/AndroidRuntime(1926): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 01:33:25.799: E/AndroidRuntime(1926): at java.lang.reflect.Method.invoke(Method.java:515)
03-05 01:33:25.799: E/AndroidRuntime(1926): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-05 01:33:25.799: E/AndroidRuntime(1926): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-05 01:33:25.799: E/AndroidRuntime(1926): at dalvik.system.NativeStart.main(Native Method)
Code is below. In Gmail.java class Inside sendEmail method at this line javax.mail.AuthenticationFailedException is coming
transport.connect(emailHost, fromEmail, fromPassword);
public void sendEmail() throws AddressException, MessagingException {
Transport transport = mailSession.getTransport("smtp");
System.out.println("emailHost="+emailHost);
System.out.println("fromEmail="+fromEmail);
System.out.println("fromPassword="+fromPassword);
transport.connect(emailHost, fromEmail, fromPassword);
Log.i("GMail","allrecipients: "+emailMessage.getAllRecipients());
transport.sendMessage(emailMessage, emailMessage.getAllRecipients());
transport.close();
Log.i("GMail", "Email sent successfully.");
}
In SendMailTask.java class I am getting NullPointerException at this line
statusDialog.setMessage(values[0].toString());
#Override
public void onProgressUpdate(Object... values) {
statusDialog.setMessage(values[0].toString());
}
can anyone help me.
You need to provide the exact email id and password of the gmail account from which you need to send the mail
I don't know about the Java part but I do know about smtp and that what you haven't included is either of the smtp ports that allows Gmail to parse it's code into an email editor follow this link from Google about smtp and rewrite you code accordingly. Link = https://support.google.com/a/answer/176600?hl=en
So I'm trying to get Guice to run in my android maven project and bundle in a 3rd party module. It runs fine in the normal junittest that does a test injection, but fails on the VM with the logcat message attached below.
What I can't understand is that there are numerous reports of Guice working fine on android . Despite this, my code seems to be failing on getBeanInfo() being called from the Guice injector. It seems I'm not the only one having this error.
Is there a work around for the Android error "Unable to resolve virtual method java/beans/PropertyDescriptor"?
So I have a couple of questions. Is the reason Guice isn't working for me, because some functionality is being invoked by my 3rd party module that would fail everywhere but isn't common? Is there a way to get more info out of Guice as to what specifically is triggering the offending getBeanInfo()? Are there work arounds? What avenues are available to me for further debugging.
The solution must be maven compatible, as answers to a similar question about tweaking eclipse settings for similar problems can't apply. Getting "Caused by: java.lang.VerifyError:"
(not that I got much mileage here anyway).
I think that all relevant files were processed by dx by the android maven plugin, as dependency:tree shows all relevant project at scope "compile", but I'm no expert here.
03-05 00:57:34.529: I/dalvikvm(2295): threadid=3: reacting to signal 3
03-05 00:57:34.568: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt'
03-05 00:57:35.059: I/dalvikvm(2295): threadid=3: reacting to signal 3
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): Could not load Finalizer in its own class loader. Loading Finalizer in the current class loader instead. As a result, you will not be able to garbage collect this class loader. To support reclaiming this class loader, either resolve the underlying issue, or move Google Collections to your system class path.
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): java.io.FileNotFoundException: com/google/inject/internal/util/$Finalizer.class
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue$DecoupledLoader.getBaseUrl(FinalizableReferenceQueue.java:269)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue$DecoupledLoader.loadFinalizer(FinalizableReferenceQueue.java:253)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue.loadFinalizer(FinalizableReferenceQueue.java:175)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$FinalizableReferenceQueue.(FinalizableReferenceQueue.java:100)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$QueueHolder.(MapMaker.java:787)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$WeakEntry.(MapMaker.java:946)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$Strength$1.newEntry(MapMaker.java:312)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.newEntry(MapMaker.java:498)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.newEntry(MapMaker.java:419)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2029)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.Annotations$AnnotationChecker.hasAnnotations(Annotations.java:116)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.Annotations.isScopeAnnotation(Annotations.java:124)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.ScopeBindingProcessor.visit(ScopeBindingProcessor.java:40)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.ScopeBindingProcessor.visit(ScopeBindingProcessor.java:30)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.spi.ScopeBinding.acceptVisitor(ScopeBinding.java:59)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.AbstractProcessor.process(AbstractProcessor.java:55)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:165)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.Guice.createInjector(Guice.java:95)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.Guice.createInjector(Guice.java:72)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.google.inject.Guice.createInjector(Guice.java:62)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at za.co.mambo.cherrylist.android.CherryListActivity.onCreate(CherryListActivity.java:27)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.Activity.performCreate(Activity.java:4465)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.os.Looper.loop(Looper.java:137)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-05 00:57:35.098: W/nalizableReferenceQueue(2295): at dalvik.system.NativeStart.main(Native Method)
03-05 00:57:35.108: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt'
03-05 00:57:35.338: D/dalvikvm(2295): GC_CONCURRENT freed 391K, 4% free 12676K/13127K, paused 8ms+5ms
03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;)
03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;)
03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;)
03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;)
03-05 00:57:35.418: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;)
03-05 00:57:35.428: W/dalvikvm(2295): VFY: unable to find class referenced in signature ([Ljava/beans/PropertyDescriptor;)
03-05 00:57:35.438: I/dalvikvm(2295): Could not find method java.beans.Introspector.getBeanInfo, referenced from method com.google.inject.internal.cglib.core.$ReflectUtils.getPropertiesHelper
03-05 00:57:35.438: W/dalvikvm(2295): VFY: unable to resolve static method 8989: Ljava/beans/Introspector;.getBeanInfo (Ljava/lang/Class;Ljava/lang/Class;)Ljava/beans/BeanInfo;
03-05 00:57:35.438: D/dalvikvm(2295): VFY: replacing opcode 0x71 at 0x000c
03-05 00:57:35.458: W/dalvikvm(2295): VFY: unable to resolve exception class 1373 (Ljava/beans/IntrospectionException;)
03-05 00:57:35.458: W/dalvikvm(2295): VFY: unable to find exception handler at addr 0x4e
03-05 00:57:35.458: W/dalvikvm(2295): VFY: rejected Lcom/google/inject/internal/cglib/core/$ReflectUtils;.getPropertiesHelper (Ljava/lang/Class;ZZ)[Ljava/beans/PropertyDescriptor;
03-05 00:57:35.458: W/dalvikvm(2295): VFY: rejecting opcode 0x0d at 0x004e
03-05 00:57:35.458: W/dalvikvm(2295): VFY: rejected Lcom/google/inject/internal/cglib/core/$ReflectUtils;.getPropertiesHelper (Ljava/lang/Class;ZZ)[Ljava/beans/PropertyDescriptor;
03-05 00:57:35.458: W/dalvikvm(2295): Verifier rejected class Lcom/google/inject/internal/cglib/core/$ReflectUtils;
03-05 00:57:35.488: D/AndroidRuntime(2295): Shutting down VM
03-05 00:57:35.498: W/dalvikvm(2295): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
03-05 00:57:35.508: I/dalvikvm(2295): threadid=3: reacting to signal 3
03-05 00:57:35.548: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt'
03-05 00:57:35.568: E/AndroidRuntime(2295): FATAL EXCEPTION: main
03-05 00:57:35.568: E/AndroidRuntime(2295): java.lang.RuntimeException: Unable to start activity ComponentInfo{za.co.mambo.cherrylist.android/za.co.mambo.cherrylist.android.CherryListActivity}: com.google.inject.internal.util.$ComputationException: java.lang.VerifyError: com/google/inject/internal/cglib/core/$ReflectUtils
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.os.Looper.loop(Looper.java:137)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-05 00:57:35.568: E/AndroidRuntime(2295): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 00:57:35.568: E/AndroidRuntime(2295): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-05 00:57:35.568: E/AndroidRuntime(2295): at dalvik.system.NativeStart.main(Native Method)
03-05 00:57:35.568: E/AndroidRuntime(2295): Caused by: com.google.inject.internal.util.$ComputationException: java.lang.VerifyError: com/google/inject/internal/cglib/core/$ReflectUtils
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.FailableCache.get(FailableCache.java:50)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:125)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:521)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:847)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.Guice.createInjector(Guice.java:95)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.Guice.createInjector(Guice.java:72)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.Guice.createInjector(Guice.java:62)
03-05 00:57:35.568: E/AndroidRuntime(2295): at za.co.mambo.cherrylist.android.CherryListActivity.onCreate(CherryListActivity.java:27)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.Activity.performCreate(Activity.java:4465)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-05 00:57:35.568: E/AndroidRuntime(2295): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-05 00:57:35.568: E/AndroidRuntime(2295): ... 11 more
03-05 00:57:35.568: E/AndroidRuntime(2295): Caused by: java.lang.VerifyError: com/google/inject/internal/cglib/core/$ReflectUtils
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.reflect.$FastClassEmitter.(FastClassEmitter.java:67)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass(FastClass.java:72)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:216)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:64)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.BytecodeGen.newFastClass(BytecodeGen.java:207)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:53)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:153)
03-05 00:57:35.568: E/AndroidRuntime(2295): at com.google.inject.internal
03-05 00:57:36.178: I/dalvikvm(2295): threadid=3: reacting to signal 3
03-05 00:57:36.188: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt'
03-05 00:57:36.530: I/dalvikvm(2295): threadid=3: reacting to signal 3
03-05 00:57:36.538: I/dalvikvm(2295): Wrote stack traces to '/data/anr/traces.txt'
The dalvik vm does not support aspected oriented programming so you can not use the plain JVM Guice. You have to use the no_aop version.
With a Maven build use
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<classifier>no_aop</classifier>
</dependency>
to get the no_aop jar into your build and apk.
Of course you can also look at using RoboGuice.
I'm trying to retrieve a name stred in SQLite table, despite the database has 11 or more records, when I try to retrieve any name from the stored records, The App. Crashs.
Java code:
OnClickListener btn_NavaigateListsner = new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (!btn_Save.isEnabled()) {
int c = mpoh.getCurrentRowNumber();
Toast.makeText(getBaseContext(), ""+mpoh.getMP_Name(0), Toast.LENGTH_SHORT).show();
Bundle bundle = new Bundle();
//bundle.putString("name", mpoh.getMP_Name(c));
//bundle.putDouble("lat", mpoh.getMP_Lat(c));
//bundle.putDouble("lng", mpoh.getMP_Lng(c));
//bundle.putString("date", mpoh.getMP_Date(c));
//bundle.putString("time", mpoh.getMP_Time(c));
intent01 = new Intent(MPData.this, MPInfo.class);
intent01.putExtras(bundle);
startActivity(intent01);
}// End of If
}
};
Method that retrieves the stored name:
public String getMP_Name(long id) {
SQLiteDatabase db = this.getReadableDatabase();
SQLiteCursor c = (SQLiteCursor) db.rawQuery("SELECT name FROM MPData WHERE "+
BaseColumns._ID+" = "+
Long.toString(id) +" AND name IS NOT NULL ", null);
c.moveToFirst();
String r = c.getString(0);
c.close();
db.close();
return r;
}
some of LogCat's output:
03-05 12:16:48.288: E/AndroidRuntime(973): FATAL EXCEPTION: main
03-05 12:16:48.288: E/AndroidRuntime(973): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
03-05 12:16:48.288: E/AndroidRuntime(973): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.androidbook.MP.MP_DB.getMP_Name(MP_DB.java:45)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.androidbook.MP.MPData$1.onClick(MPData.java:57)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.view.View.performClick(View.java:2485)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.view.View$PerformClick.run(View.java:9080)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.os.Handler.handleCallback(Handler.java:587)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.os.Looper.loop(Looper.java:130)
03-05 12:16:48.288: E/AndroidRuntime(973): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-05 12:16:48.288: E/AndroidRuntime(973): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:16:48.288: E/AndroidRuntime(973): at java.lang.reflect.Method.invoke(Method.java:507)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-05 12:16:48.288: E/AndroidRuntime(973): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-05 12:16:48.288: E/AndroidRuntime(973): at dalvik.system.NativeStart.main(Native Method)
03-05 12:32:19.897: E/AndroidRuntime(1022): FATAL EXCEPTION: main
03-05 12:32:19.897: E/AndroidRuntime(1022): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.androidbook.MP.MP_DB.getMP_Name(MP_DB.java:45)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.androidbook.MP.MPData$1.onClick(MPData.java:57)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.view.View.performClick(View.java:2485)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.view.View$PerformClick.run(View.java:9080)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.os.Handler.handleCallback(Handler.java:587)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.os.Handler.dispatchMessage(Handler.java:92)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.os.Looper.loop(Looper.java:130)
03-05 12:32:19.897: E/AndroidRuntime(1022): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-05 12:32:19.897: E/AndroidRuntime(1022): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:32:19.897: E/AndroidRuntime(1022): at java.lang.reflect.Method.invoke(Method.java:507)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-05 12:32:19.897: E/AndroidRuntime(1022): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-05 12:32:19.897: E/AndroidRuntime(1022): at dalvik.system.NativeStart.main(Native Method)
03-05 12:39:24.627: E/AndroidRuntime(1093): FATAL EXCEPTION: main
03-05 12:39:24.627: E/AndroidRuntime(1093): android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.androidbook.MP.MP_DB.getMP_Name(MP_DB.java:45)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.androidbook.MP.MPData$1.onClick(MPData.java:57)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.View.performClick(View.java:2485)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.View.onKeyUp(View.java:4257)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.widget.TextView.onKeyUp(TextView.java:4587)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.KeyEvent.dispatch(KeyEvent.java:1280)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.View.dispatchKeyEvent(View.java:3855)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1687)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1120)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.app.Activity.dispatchKeyEvent(Activity.java:2073)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1663)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2560)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2535)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.view.ViewRoot.handleMessage(ViewRoot.java:1867)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.os.Looper.loop(Looper.java:130)
03-05 12:39:24.627: E/AndroidRuntime(1093): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-05 12:39:24.627: E/AndroidRuntime(1093): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:39:24.627: E/AndroidRuntime(1093): at java.lang.reflect.Method.invoke(Method.java:507)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-05 12:39:24.627: E/AndroidRuntime(1093): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-05 12:39:24.627: E/AndroidRuntime(1093): at dalvik.system.NativeStart.main(Native Method)
The code looks fine to me. Are you 100% sure you have an entry in your DB with an _id corresponding to 0?
If you call getMP_Name with an invalid _id then the exception will get raised as you posted it.
You should check for this case as follows:
if (c.getCount()==0) return "";
// rest of code
But I wouldn't do it like this anyway because your current implementation of getMP_XXX is very inefficient because you hit the database for each field and each row. You should minimise your number of queries and then iterate over the resulting cursor.
Look at the following line :
String r = c.getString(0);
You are not safe checking your cursor and just assuming a result was recieved.
Check you SQL query and add a safe check for making sure your cursor has retrieved results.
My application always crashes when I try to create a Notification, only crashes on Android 3.0.
03-05 21:23:00.774: ERROR/ActivityManager(66): Activity Manager Crash
03-05 21:23:00.774: ERROR/ActivityManager(66): java.lang.IllegalArgumentException: Null intent at index 0
03-05 21:23:00.774: ERROR/ActivityManager(66): at com.android.server.am.ActivityManagerService.getIntentSender(ActivityManagerService.java:3907)
03-05 21:23:00.774: ERROR/ActivityManager(66): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:799)
03-05 21:23:00.774: ERROR/ActivityManager(66): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1516)
03-05 21:23:00.774: ERROR/ActivityManager(66): at android.os.Binder.execTransact(Binder.java:320)
03-05 21:23:00.774: ERROR/ActivityManager(66): at dalvik.system.NativeStart.run(Native Method)
03-05 21:23:00.784: WARN/dalvikvm(458): threadid=9: thread exiting with uncaught exception (group=0x40014760)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): FATAL EXCEPTION: Thread-10
03-05 21:23:00.814: ERROR/AndroidRuntime(458): java.lang.IllegalArgumentException: Null intent at index 0
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.os.Parcel.readException(Parcel.java:1326)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.os.Parcel.readException(Parcel.java:1276)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.app.ActivityManagerProxy.getIntentSender(ActivityManagerNative.java:2356)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.app.PendingIntent.getActivity(PendingIntent.java:195)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at com.perlapps.myantivirus.scanmethodes.UpdateDatabase$1.run(UpdateDatabase.java:244)
Has anybody got an idea how to fix it???
Edit: Works perfectly on 1.5 to 2.3
NotificationManager meinNM = (NotificationManager) oContext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification meinNotofication = new Notification(R.drawable.icon,"HELLO",System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(oContext.getApplicationContext(),0, null, 0);
meinNotofication.setLatestEventInfo(oContext.getApplicationContext(),"HELLO","HELLO",pendingIntent);
meinNM.notify(97, meinNotofication);
Use a valid PendingIntent. Yours is invalid -- null is not a valid third parameter to getActivity(). Also, get rid of getApplicationContext() -- oContext is a Context and is all you need.
Hey guys
I simply want to downgrade my api level 8 to 7 so that i can run the
application both on 2.2 and 2.1 devices.
The application is running perfectly fine on 2.2 and is having problem
working on 2.1
I have done changes in manifest.xml and project -> properties
My application basically uses sax parser , facebook sdk , twitter
connect
This is the log cat:
03-05 12:32:13.553: WARN/dalvikvm(232): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
03-05 12:32:13.563: ERROR/AndroidRuntime(232): Uncaught handler: thread main exiting due to uncaught exception
03-05 12:32:13.623: ERROR/AndroidRuntime(232): java.lang.NullPointerException
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.test.activity.MyActivity$FetchTopMusic.onPostExecute(MusicScreen.java:161)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.test.activity.MyActivity$FetchTopMusic.onPostExecute(MusicScreen.java:1)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.AsyncTask.finish(AsyncTask.java:417)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.AsyncTask.access$300(AsyncTask.java:127)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.os.Looper.loop(Looper.java:123)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at java.lang.reflect.Method.invoke(Method.java:521)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-05 12:32:13.623: ERROR/AndroidRuntime(232): at dalvik.system.NativeStart.main(Native Method)
And i get this message after the splash screen.
Music Screen has async task which is calling various classes in various packages for parsing the xml content.
Is this a problem in xml parser??
The line 161 is :-
for (int i = 0; i < tracks.size(); i++)
Where tracks is an arrayList and all this code is working fine in 2.2
Have you checked in the default properties and set the target to 7? Then check whether it is possible or not.
Let me know...