How do I find and fix an uncaught exception? - android

I don't know how to figure out where an uncaught exception is coming from. I have looked through the stackoverflow posts and tried looking for several of the solutions. As far as I can tell, I have my activity, "Monitor", listed in my manifest and it is part of the package. But I get a null pointer exception when I start the "Monitor" activity. What should I be looking for to find this exception?
02-03 21:44:14.192: E/Trace(19701): error opening trace file: No such file or directory (2)
02-03 21:44:14.262: I/BugSenseHandler(19701): Registering default exceptions handler
02-03 21:44:14.633: I/Setup(19701): Setup activity created
02-03 21:44:14.813: I/BugSenseHandler(19701): Flushing...
02-03 21:44:14.823: I/BugSenseHandler(19701): Registering default exceptions handler
02-03 21:44:15.023: W/BugSenseHandler(19701): Transmitting ping Exception No peer certificate
02-03 21:44:15.403: I/Adreno200-EGLSUB(19701): <ConfigWindowMatch:2087>: Format RGBA_8888.
02-03 21:44:15.594: E/(19701): <s3dReadConfigFile:75>: Can't open file for reading
02-03 21:44:15.594: E/(19701): <s3dReadConfigFile:75>: Can't open file for reading
02-03 21:44:19.318: W/dalvikvm(19701): threadid=1: thread exiting with uncaught exception (group=0x41bfb438)
02-03 21:44:22.401: E/AndroidRuntime(19701): FATAL EXCEPTION: main
02-03 21:44:22.401: E/AndroidRuntime(19701): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mpeterson.sousvide/com.mpeterson.sousvide.Monitor}: java.lang.NullPointerException
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2024)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.ActivityThread.access$600(ActivityThread.java:139)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1231)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.os.Looper.loop(Looper.java:137)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.ActivityThread.main(ActivityThread.java:5021)
02-03 21:44:22.401: E/AndroidRuntime(19701): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 21:44:22.401: E/AndroidRuntime(19701): at java.lang.reflect.Method.invoke(Method.java:511)
02-03 21:44:22.401: E/AndroidRuntime(19701): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
02-03 21:44:22.401: E/AndroidRuntime(19701): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
02-03 21:44:22.401: E/AndroidRuntime(19701): at dalvik.system.NativeStart.main(Native Method)
02-03 21:44:22.401: E/AndroidRuntime(19701): Caused by: java.lang.NullPointerException
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.Activity.findViewById(Activity.java:1851)
02-03 21:44:22.401: E/AndroidRuntime(19701): at com.mpeterson.sousvide.Monitor.<init>(Monitor.java:51)
02-03 21:44:22.401: E/AndroidRuntime(19701): at java.lang.Class.newInstanceImpl(Native Method)
02-03 21:44:22.401: E/AndroidRuntime(19701): at java.lang.Class.newInstance(Class.java:1319)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
02-03 21:44:22.401: E/AndroidRuntime(19701): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
02-03 21:44:22.401: E/AndroidRuntime(19701): ... 11 more

Provided that you have editTextCurTemp defined as TextView in your_layout_file.xml, you must call
setContentView(R.layout.your_layout_file)
BEFORE you do any findViewById(), otherwise you will get NPE.

Related

Unable to start activity ComponentInfo android.view.InflateException: Binary XML file line #27: Error inflating class fragment

When I run YouTube WatchMe android project, I get below exception:
02-03 14:06:36.865: E/AndroidRuntime(14244): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.apps.watchme/com.google.android.apps.watchme.MainActivity}: android.view.InflateException: Binary XML file line #27: Error inflating class fragment
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.ActivityThread.access$700(ActivityThread.java:150)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.os.Looper.loop(Looper.java:137)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.ActivityThread.main(ActivityThread.java:5283)
02-03 14:06:36.865: E/AndroidRuntime(14244): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 14:06:36.865: E/AndroidRuntime(14244): at java.lang.reflect.Method.invoke(Method.java:511)
02-03 14:06:36.865: E/AndroidRuntime(14244): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
02-03 14:06:36.865: E/AndroidRuntime(14244): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
02-03 14:06:36.865: E/AndroidRuntime(14244): at dalvik.system.NativeStart.main(Native Method)
02-03 14:06:36.865: E/AndroidRuntime(14244): Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class fragment
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-03 14:06:36.865: E/AndroidRuntime(14244): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:364)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.Activity.setContentView(Activity.java:1930)
02-03 14:06:36.865: E/AndroidRuntime(14244): at com.google.android.apps.watchme.MainActivity.onCreate(MainActivity.java:82)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.Activity.performCreate(Activity.java:5283)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
02-03 14:06:36.865: E/AndroidRuntime(14244): ... 11 more
02-03 14:06:36.865: E/AndroidRuntime(14244): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.apps.watchme.EventsListFragment: make sure class name exists, is public, and has an empty constructor that is public
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.Fragment.instantiate(Fragment.java:596)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.Fragment.instantiate(Fragment.java:560)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.Activity.onCreateView(Activity.java:4864)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:686)
02-03 14:06:36.865: E/AndroidRuntime(14244): ... 21 more
02-03 14:06:36.865: E/AndroidRuntime(14244): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.apps.watchme.EventsListFragment" on path: /data/app/com.google.android.apps.watchme-1.apk
02-03 14:06:36.865: E/AndroidRuntime(14244): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-03 14:06:36.865: E/AndroidRuntime(14244): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-03 14:06:36.865: E/AndroidRuntime(14244): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-03 14:06:36.865: E/AndroidRuntime(14244): at android.app.Fragment.instantiate(Fragment.java:582)
02-03 14:06:36.865: E/AndroidRuntime(14244): ... 24 more
Code:
public class MainActivity extends Activity implements
EventsListFragment.Callbacks {
private EventsListFragment mEventsListFragment;
#Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mEventsListFragment = (EventsListFragment) getFragmentManager()
.findFragmentById(R.id.list_fragment);
}
}
I checked everything my package name, xmls but I don't why I am getting this one.
Check if EventsListFragment is public
in one of your layout files(activity_main) you are passing
com.google.android.apps.watchme.EventsListFragment as an address for your fragment
, check if the address for EventsListFragment is correct
Adding android-support-v4.jar solved my problem. Also, changed priority to top & checked it in project properties section.

"FATAL EXCEPTION: main" on success callback for camera in cordova

I am using cordova 3.6 and android 4.4 and i used a simple example for opening a camera or choose picture from gallery but on every success callback for camera getting below error
02-03 16:39:04.279: E/AndroidRuntime(3403): FATAL EXCEPTION: main
02-03 16:39:04.279: E/AndroidRuntime(3403): java.lang.RuntimeException: Unable to resume activity {com.CameraOptionApp/com.CameraOptionApp.CameraOptionApp}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=18, result=-1, data=Intent { dat=content://media/external/images/media/5027 }} to activity {com.CameraOptionApp/com.CameraOptionApp.CameraOptionApp}: java.lang.NullPointerException
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2760)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2216)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.access$600(ActivityThread.java:149)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.os.Looper.loop(Looper.java:153)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.main(ActivityThread.java:5086)
02-03 16:39:04.279: E/AndroidRuntime(3403): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 16:39:04.279: E/AndroidRuntime(3403): at java.lang.reflect.Method.invoke(Method.java:511)
02-03 16:39:04.279: E/AndroidRuntime(3403): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
02-03 16:39:04.279: E/AndroidRuntime(3403): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
02-03 16:39:04.279: E/AndroidRuntime(3403): at dalvik.system.NativeStart.main(Native Method)
02-03 16:39:04.279: E/AndroidRuntime(3403): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=18, result=-1, data=Intent { dat=content://media/external/images/media/5027 }} to activity {com.CameraOptionApp/com.CameraOptionApp.CameraOptionApp}: java.lang.NullPointerException
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.deliverResults(ActivityThread.java:3302)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2715)
02-03 16:39:04.279: E/AndroidRuntime(3403): ... 12 more
02-03 16:39:04.279: E/AndroidRuntime(3403): Caused by: java.lang.NullPointerException
02-03 16:39:04.279: E/AndroidRuntime(3403): at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:779)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.Activity.dispatchActivityResult(Activity.java:5204)
02-03 16:39:04.279: E/AndroidRuntime(3403): at android.app.ActivityThread.deliverResults(ActivityThread.java:3298)
02-03 16:39:04.279: E/AndroidRuntime(3403): ... 13 more
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): Logger$UncaughtExceptionHandler.uncaughtException in Logger.java:438 :: Uncaught Exception
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): java.lang.RuntimeException: Unable to resume activity {com.CameraOptionApp/com.CameraOptionApp.CameraOptionApp}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=18, result=-1, data=Intent { dat=content://media/external/images/media/5027 }} to activity {com.CameraOptionApp/com.CameraOptionApp.CameraOptionApp}: java.lang.NullPointerException
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2760)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2216)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.access$600(ActivityThread.java:149)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.os.Looper.loop(Looper.java:153)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.main(ActivityThread.java:5086)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at java.lang.reflect.Method.invoke(Method.java:511)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at dalvik.system.NativeStart.main(Native Method)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=18, result=-1, data=Intent { dat=content://media/external/images/media/5027 }} to activity {com.CameraOptionApp/com.CameraOptionApp.CameraOptionApp}: java.lang.NullPointerException
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.deliverResults(ActivityThread.java:3302)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2715)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): ... 12 more
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): Caused by: java.lang.NullPointerException
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:779)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.Activity.dispatchActivityResult(Activity.java:5204)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): at android.app.ActivityThread.deliverResults(ActivityThread.java:3298)
02-03 16:39:04.287: E/com.worklight.common.Logger$UncaughtExceptionHandler(3403): ... 13 more
02-03 16:39:04.291: D/wl(3403): WL.doPrepareAssetsWork in WL.java:287 :: no need to check web resource integrity
I tried on different machine also but having same issue.

Hello Android Stops Unexpectedly

I have searched the internet for days and have found dozens of solutions none of which work. So I thought I'd post my situation:
I have installed eclipse and the 2.3.3 android SDK onto my laptop, put the code in for hello world (or hello android) and clicked run. The emulator starts but when the activity is run I get the message "SORRY! the application Hello Android (process com.example helloandroid) has stopped unexpectedly. Please try again"
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
and this is log cat
02-03 12:54:59.470: D/AndroidRuntime(356): Shutting down VM
02-03 12:54:59.470: W/dalvikvm(356): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-03 12:54:59.521: E/AndroidRuntime(356): FATAL EXCEPTION: main
02-03 12:54:59.521: E/AndroidRuntime(356): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.HelloAndroidActivity}: java.lang.ClassNotFoundException: com.example.helloandroid.HelloAndroidActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.helloandroid-1.apk]
02-03 12:54:59.521: E/AndroidRuntime(356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.os.Looper.loop(Looper.java:123)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-03 12:54:59.521: E/AndroidRuntime(356): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 12:54:59.521: E/AndroidRuntime(356): at java.lang.reflect.Method.invoke(Method.java:507)
02-03 12:54:59.521: E/AndroidRuntime(356): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-03 12:54:59.521: E/AndroidRuntime(356): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-03 12:54:59.521: E/AndroidRuntime(356): at dalvik.system.NativeStart.main(Native Method)
02-03 12:54:59.521: E/AndroidRuntime(356): Caused by: java.lang.ClassNotFoundException: com.example.helloandroid.HelloAndroidActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.helloandroid-1.apk]
02-03 12:54:59.521: E/AndroidRuntime(356): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
02-03 12:54:59.521: E/AndroidRuntime(356): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
02-03 12:54:59.521: E/AndroidRuntime(356): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
02-03 12:54:59.521: E/AndroidRuntime(356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
02-03 12:54:59.521: E/AndroidRuntime(356): ... 11 more
02-03 12:59:59.691: I/Process(356): Sending signal. PID: 356 SIG: 9
02-03 13:00:33.371: D/AndroidRuntime(366): Shutting down VM
02-03 13:00:33.371: W/dalvikvm(366): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-03 13:00:33.431: E/AndroidRuntime(366): FATAL EXCEPTION: main
02-03 13:00:33.431: E/AndroidRuntime(366): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.HelloAndroidActivity}: java.lang.ClassNotFoundException: com.example.helloandroid.HelloAndroidActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.helloandroid-1.apk]
02-03 13:00:33.431: E/AndroidRuntime(366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.os.Looper.loop(Looper.java:123)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-03 13:00:33.431: E/AndroidRuntime(366): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 13:00:33.431: E/AndroidRuntime(366): at java.lang.reflect.Method.invoke(Method.java:507)
02-03 13:00:33.431: E/AndroidRuntime(366): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-03 13:00:33.431: E/AndroidRuntime(366): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-03 13:00:33.431: E/AndroidRuntime(366): at dalvik.system.NativeStart.main(Native Method)
02-03 13:00:33.431: E/AndroidRuntime(366): Caused by: java.lang.ClassNotFoundException: com.example.helloandroid.HelloAndroidActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.helloandroid-1.apk]
02-03 13:00:33.431: E/AndroidRuntime(366): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
02-03 13:00:33.431: E/AndroidRuntime(366): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
02-03 13:00:33.431: E/AndroidRuntime(366): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
02-03 13:00:33.431: E/AndroidRuntime(366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
02-03 13:00:33.431: E/AndroidRuntime(366): ... 11 more
02-03 13:05:33.600: I/Process(366): Sending signal. PID: 366 SIG: 9
It seems to be something wrong with the way your emulator is set up. Did you follow this tutorial especially the "Setting up the AVD" part?
I would start the install of the emulator all over again. Also you could send him a copy of your program and if he can successfully run your project in the emulator then you know you just need to get your emulator set up correctly.
try moving your setContentView() method above your textview initialization

Java Error (Runtime Exception - Illegal Argument Exception) - Android

Here's the error message I'm getting: E/AndroidRuntime(416): java.lang.RuntimeException: Unable to start activity ComponentInfo java.lang.IllegalArgumentException. I took out the app file name/package name, but everything else is there. The app is designed to target the Gingerbread, but has a minimum SDK level for the Froyo. I'm basically get an AVR message when I try and launch the app on the AVD. The source code is ~460 lines long, so I'm not sure where the error is (there are no syntax errors, so I'm not sure what I'm doing wrong). Here's the pastebin URL for the source code that I've put up: http://pastebin.com/EtUP2CAB. I've seen some stuff about DecimalFormatSymbols and the SensorSimulator, etc., but I'm still confused. Hence, I'd appreciate some help with locating the issue here causing this error.
EDIT: Here's the error log for the last run I did:
02-03 20:51:21.724: D/AndroidRuntime(468): Shutting down VM
02-03 20:51:21.724: W/dalvikvm(468): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-03 20:51:21.784: E/AndroidRuntime(468): FATAL EXCEPTION: main
02-03 20:51:21.784: E/AndroidRuntime(468): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.deitel.flagquizgame/com.deitel.flagquizgame.FlagQuizGame}: java.lang.IllegalArgumentException
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.os.Looper.loop(Looper.java:123)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-03 20:51:21.784: E/AndroidRuntime(468): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 20:51:21.784: E/AndroidRuntime(468): at java.lang.reflect.Method.invoke(Method.java:507)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-03 20:51:21.784: E/AndroidRuntime(468): at dalvik.system.NativeStart.main(Native Method)
02-03 20:51:21.784: E/AndroidRuntime(468): Caused by: java.lang.IllegalArgumentException
02-03 20:51:21.784: E/AndroidRuntime(468): at java.util.Random.nextInt(Random.java:186)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.deitel.flagquizgame.FlagQuizGame.resetQuiz(FlagQuizGame.java:136)
02-03 20:51:21.784: E/AndroidRuntime(468): at com.deitel.flagquizgame.FlagQuizGame.onCreate(FlagQuizGame.java:92)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-03 20:51:21.784: E/AndroidRuntime(468): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-03 20:51:21.784: E/AndroidRuntime(468): ... 11 more
02-03 20:51:27.464: I/Process(468): Sending signal. PID: 468 SIG: 9
seems in line
int randomIndex = random.nextInt(numberOfFlags);
numberOfFlags are not positive number, its 0 or less than 0, check numberOfFlags value by debugging.

class not found exception using backward compatibility library in android

I have developed project in android3.1 and i am trying to run in android2.1 emulator . I have added android-support-v4.jar and specified
in manifest file .can anybody tell what is problem how to solve?
02-03 15:06:08.623: E/AndroidRuntime(223): Uncaught handler: thread main exiting due to uncaught exception
02-03 15:06:08.641: E/AndroidRuntime(223): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.fragment/com.test.fragment.FragmentTestWebActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.os.Handler.dispatchMessage(Handler.java:99)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.os.Looper.loop(Looper.java:123)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.ActivityThread.main(ActivityThread.java:4363)
02-03 15:06:08.641: E/AndroidRuntime(223): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 15:06:08.641: E/AndroidRuntime(223): at java.lang.reflect.Method.invoke(Method.java:521)
02-03 15:06:08.641: E/AndroidRuntime(223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-03 15:06:08.641: E/AndroidRuntime(223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-03 15:06:08.641: E/AndroidRuntime(223): at dalvik.system.NativeStart.main(Native Method)
02-03 15:06:08.641: E/AndroidRuntime(223): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-03 15:06:08.641: E/AndroidRuntime(223): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.Activity.setContentView(Activity.java:1622)
02-03 15:06:08.641: E/AndroidRuntime(223): at com.test.fragment.FragmentTestWebActivity.onCreate(FragmentTestWebActivity.java:13)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
02-03 15:06:08.641: E/AndroidRuntime(223): ... 11 more
02-03 15:06:08.641: E/AndroidRuntime(223): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader#48079860
02-03 15:06:08.641: E/AndroidRuntime(223): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-03 15:06:08.641: E/AndroidRuntime(223): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-03 15:06:08.641: E/AndroidRuntime(223): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
02-03 15:06:08.641: E/AndroidRuntime(223): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-03 15:06:08.641: E/AndroidRuntime(223): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-03 15:06:08.641: E/AndroidRuntime(223): ... 20 more
thanks
Make sure to import the Fragment from the library. Fragment in later Android versions and Fragment in the compatibility library have different packages!

Categories

Resources