android: location code sample crashes - android

I have downloaded the sample code for location from
https://code.google.com/p/android-protips-location/
I am trying to run it to see but it always crashes after app launch.
I have checked the manifest but I didnt find anything wrong. Has any one faced similar problem with the above sample code.
Here is the crash log.
03-19 12:06:05.456: D/AndroidRuntime(9185): Shutting down VM 03-19
12:06:05.456: W/dalvikvm(9185): threadid=1: thread exiting with
uncaught exception (group=0x414e62a0) 03-19 12:06:05.503:
E/AndroidRuntime(9185): FATAL EXCEPTION: main 03-19 12:06:05.503:
E/AndroidRuntime(9185): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.radioactiveyak.location_best_practices/com.radioactiveyak.location_best_practices.UI.PlaceActivity}:
java.lang.ClassNotFoundException:
com.radioactiveyak.location_best_practices.UI.PlaceActivity 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2021)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.access$600(ActivityThread.java:140) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.os.Handler.dispatchMessage(Handler.java:99) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.os.Looper.loop(Looper.java:137) 03-19 12:06:05.503:
E/AndroidRuntime(9185): at
android.app.ActivityThread.main(ActivityThread.java:4895) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
java.lang.reflect.Method.invokeNative(Native Method) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
java.lang.reflect.Method.invoke(Method.java:511) 03-19 12:06:05.503:
E/AndroidRuntime(9185): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
dalvik.system.NativeStart.main(Native Method) 03-19 12:06:05.503:
E/AndroidRuntime(9185): Caused by: java.lang.ClassNotFoundException:
com.radioactiveyak.location_best_practices.UI.PlaceActivity 03-19
12:06:05.503: E/AndroidRuntime(9185): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461) 03-19
12:06:05.503: E/AndroidRuntime(9185): at
android.app.Instrumentation.newActivity(Instrumentation.java:1068)
03-19 12:06:05.503: E/AndroidRuntime(9185): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2012)
03-19 12:06:05.503: E/AndroidRuntime(9185): ... 11 more

Did you try project -> Clean? Do you have to add the permision in manifest of location?

I had the same issue.
I solved it by going to: Project Properties -> Java Build Path -> Order and Export Tab
And then ive put the checkmark on the "android-support-v4.jar"

Related

My android emulator in eclipse, does not start

i have this problem:
when i try start my emulator in eclipse i wait 15 minutes and it is not started.
I try reinstall eclipse but emulator still dont working.
03-19 15:26:38.960: E/Installer(438): connection failed
03-19 15:26:39.530: E/System(438): ******************************************
03-19 15:26:39.530: E/System(438): ************ Failure starting bootstrap service
03-19 15:26:39.530: E/System(438): java.lang.NullPointerException
03-19 15:26:39.530: E/System(438): at com.android.server.firewall.IntentFirewall.readRulesDir(IntentFirewall.java:271)
03-19 15:26:39.530: E/System(438): at com.android.server.firewall.IntentFirewall.<init>(IntentFirewall.java:114)
03-19 15:26:39.530: E/System(438): at com.android.server.am.ActivityManagerService.main(ActivityManagerService.java:1804)
03-19 15:26:39.530: E/System(438): at com.android.server.ServerThread.initAndLoop(SystemServer.java:196)
03-19 15:26:39.530: E/System(438): at com.android.server.SystemServer.main(SystemServer.java:1179)
03-19 15:26:39.530: E/System(438): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 15:26:39.530: E/System(438): at java.lang.reflect.Method.invoke(Method.java:515)
03-19 15:26:39.530: E/System(438): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-19 15:26:39.530: E/System(438): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-19 15:26:39.530: E/System(438): at dalvik.system.NativeStart.main(Native Method)
03-19 15:26:39.630: E/AndroidRuntime(438): *** FATAL EXCEPTION IN SYSTEM PROCESS: WindowManager
03-19 15:26:39.630: E/AndroidRuntime(438): java.lang.NullPointerException
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.LocalDisplayAdapter$LocalDisplayDevice.getDisplayDeviceInfoLocked(LocalDisplayAdapter.java:147)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService.handleDisplayDeviceAddedLocked(DisplayManagerService.java:852)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService.handleDisplayDeviceAdded(DisplayManagerService.java:841)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService.access$1100(DisplayManagerService.java:96)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayManagerService$DisplayAdapterListener.onDisplayDeviceEvent(DisplayManagerService.java:1281)
03-19 15:26:39.630: E/AndroidRuntime(438): at com.android.server.display.DisplayAdapter$1.run(DisplayAdapter.java:108)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.Handler.handleCallback(Handler.java:733)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.Handler.dispatchMessage(Handler.java:95)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.Looper.loop(Looper.java:136)
03-19 15:26:39.630: E/AndroidRuntime(438): at android.os.HandlerThread.run(HandlerThread.java:61)
03-19 15:26:39.640: E/AndroidRuntime(438): Error reporting crash
03-19 15:26:39.640: E/AndroidRuntime(438): java.lang.NullPointerException
03-19 15:26:39.640: E/AndroidRuntime(438): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:84)
03-19 15:26:39.640: E/AndroidRuntime(438): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-19 15:26:39.640: E/AndroidRuntime(438): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-19 15:27:46.600: E/Installer(796): connection failed
03-19 15:27:47.120: E/System(796): ******************************************
03-19 15:27:47.120: E/System(796): ************ Failure starting bootstrap service
03-19 15:27:47.120: E/System(796): java.lang.NullPointerException
03-19 15:27:47.120: E/System(796): at com.android.server.firewall.IntentFirewall.readRulesDir(IntentFirewall.java:271)
03-19 15:27:47.120: E/System(796): at com.android.server.firewall.IntentFirewall.<init>(IntentFirewall.java:114)
03-19 15:27:47.120: E/System(796): at com.android.server.am.ActivityManagerService.main(ActivityManagerService.java:1804)
03-19 15:27:47.120: E/System(796): at com.android.server.ServerThread.initAndLoop(SystemServer.java:196)
03-19 15:27:47.120: E/System(796): at com.android.server.SystemServer.main(SystemServer.java:1179)
03-19 15:27:47.120: E/System(796): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 15:27:47.120: E/System(796): at java.lang.reflect.Method.invoke(Method.java:515)
03-19 15:27:47.120: E/System(796): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-19 15:27:47.120: E/System(796): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-19 15:27:47.120: E/System(796): at dalvik.system.NativeStart.main(Native Method)
I install eclipse with adt with sdk for android and i can not start emulator.
Thank you for help.
Try opening emulator with less device screen size like 3.2'and wait for emulator to launch,on first occasion it might take some time.
Emulator with high config and screen size takes ages to open and sometimes does not even launch no matter what.
I had the same problem and i opened emulator using small screen resolution and boom it worked. :) Try it.

Cocos2D-x sample application crashes on launch

I tried to build the Cocos2D-x testCpp sample project (Cocos2D-x 2.2.2) on my Android device using the command line interface as described in the Readme.md file:
$ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/
$ export NDK_ROOT=/path/to/ndk
$ ./build_native.sh
$ ant debug install
If the last command results in sdk.dir missing error then do:
$ android list target
$ android update project -p . -t (id from step 6)
$ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6)
I can install the app on my device (Galaxy S4) but the application crashes immediately after the launch telling me the application was stopped.
Any idea what I can do to fix that problem?
I am not sure how to use logcat within the CLI, so I startet the sample application using eclipse (the error here is the same: application crashes after launch) and post the logcat info shown by eclipse:
03-19 10:49:22.785: W/dalvikvm(6591): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/cocos2dx/hellocpp/HelloCpp;
03-19 10:49:22.785: W/dalvikvm(6591): Class init failed in newInstance call (Lorg/cocos2dx/hellocpp/HelloCpp;)
03-19 10:49:22.785: D/AndroidRuntime(6591): Shutting down VM
03-19 10:49:22.785: W/dalvikvm(6591): threadid=1: thread exiting with uncaught exception (group=0x4195f898)
03-19 10:49:22.785: E/AndroidRuntime(6591): FATAL EXCEPTION: main
03-19 10:49:22.785: E/AndroidRuntime(6591): java.lang.UnsatisfiedLinkError: Couldn't load hellocpp from loader dalvik.system.PathClassLoader[dexPath=/data/app/org.cocos2dx.hellocpp-1.apk,libraryPath=/data/app-lib/org.cocos2dx.hellocpp-1]: findLibrary returned null
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Runtime.loadLibrary(Runtime.java:355)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.System.loadLibrary(System.java:525)
03-19 10:49:22.785: E/AndroidRuntime(6591): at org.cocos2dx.hellocpp.HelloCpp.(HelloCpp.java:37)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Class.newInstanceImpl(Native Method)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Class.newInstance(Class.java:1130)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.os.Looper.loop(Looper.java:137)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.main(ActivityThread.java:5419)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.reflect.Method.invoke(Method.java:525)
03-19 10:49:22.785: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
03-19 10:49:22.785: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
03-19 10:49:22.785: E/AndroidRuntime(6591): at dalvik.system.NativeStart.main(Native Method)
seems that your building is not successful according to the log. no hellocpp.so is generated. so it crashes when you call the method
loadLibrary();
you can check this under youPath/proj.android/libs/armeabi , see if there's a libxxx.so file.
Every time this has happened to me it has always been because I forgot to run ./build_native.sh in the "proj.android" folder of the project in question. #Lorin actually noted the symptom that reminded me. A reason that a libxxx.so file would be missing is the ./build_native.sh script has yet to be run
When you run eclipse to build it is happening in the background. When you compile from command line you need to remember to to have run the script at least once (and every time (if) you ever make a change to the cocos2dx framework itself.) I frequently forget to do that for EVERY project thereafter.

Android ComponentInfo ClassNotFoundException on some devices

Please help to understand strange application behaviour.
In almost all devices in production everything is OK, I'm using ACRA to collect crash reports. But here is what I've got from Alpha GTR device:
ComponentInfo{com.xxxxxxxxxxx /com.xxxxxxxxxxx.xxxxActivity}: java.lang.ClassNotFoundException: com.xxxxxxxxxxx.xxxxActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.access$600(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.xxxxxxxxxxx.xxxxActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
... 11 more
java.lang.ClassNotFoundException: com.xxxxxxxxxxx.xxxxActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.access$600(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
So application failed to start with strange exception. I've already checked SO questions about it, and just adding libraries as Unable to instantiate activity... Caused by ClassNotFoundException doesn't help here.
Could it be some device-specific exception? My app uses Camera, Google Maps and GPS.
Maybe you have to check if GPS or Camera are supported by the device first?
LocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

without inserting the entire project code how to call classes from one project into another project in android

01-28 13:51:17.332: D/AndroidRuntime(766): Shutting down VM
01-28 13:51:17.332: W/dalvikvm(766): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-28 13:51:17.522: E/AndroidRuntime(766): FATAL EXCEPTION: main
01-28 13:51:17.522: E/AndroidRuntime(766): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.canadaqbank.usmle/com.canadaqbank.usmle.USMLEActivity}: java.lang.ClassNotFoundException: com.canadaqbank.usmle.USMLEActivity in loader dalvik.system.PathClassLoader[/data/app/com.canadaqbank.usmle-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.os.Looper.loop(Looper.java:123)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.reflect.Method.invoke(Method.java:521)
01-28 13:51:17.522: E/AndroidRuntime(766): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-28 13:51:17.522: E/AndroidRuntime(766): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-28 13:51:17.522: E/AndroidRuntime(766): at dalvik.system.NativeStart.main(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766): Caused by: java.lang.ClassNotFoundException: com.canadaqbank.usmle.USMLEActivity in loader dalvik.system.PathClassLoader[/data/app/com.canadaqbank.usmle-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
01-28 13:51:17.522: E/AndroidRuntime(766): ... 11 more
I want to call one project classes into another project without keep all the entire code in this project, I added it in the build path and also declared that class in the manifest file but when I call it gives me a android.view.InflateException: Binary XML file line #8: Error inflating class . I am calling it from intent.
android.view.InflateException: Binary XML file line #8: Error inflating class com.bank.Header
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.os.Looper.loop(Looper.java:123)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-28 10:42:57.503: E/AndroidRuntime(309): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 10:42:57.503: E/AndroidRuntime(309): at java.lang.reflect.Method.invoke(Method.java:521)
01-28 10:42:57.503: E/AndroidRuntime(309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-28 10:42:57.503: E/AndroidRuntime(309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-28 10:42:57.503: E/AndroidRuntime(309): at dalvik.system.NativeStart.main(Native Method)
01-28 10:42:57.503: E/AndroidRuntime(309): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.bank.Header
01-28 10:42:57.503: E/AndroidRuntime(309): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-28 10:42:57.503: E/AndroidRuntime(309): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.Activity.setContentView(Activity.java:1647)
01-28 10:42:57.503: E/AndroidRuntime(309): at com.bank.us.USActivity.onCreate(USActivity.java:25)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-28 10:42:57.503: E/AndroidRuntime(309): ... 11 more
01-28 10:42:57.503: E/AndroidRuntime(309): Caused by: java.lang.reflect.InvocationTargetException
01-28 10:42:57.503: E/AndroidRuntime(309): at com.bank.Header.<init>(Header.java:223)
01-28 10:42:57.503: E/AndroidRuntime(309): at java.lang.reflect.Constructor.constructNative(Native Method)
01-28 10:42:57.503: E/AndroidRuntime(309): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
01-28 10:42:57.503: E/AndroidRuntime(309): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
01-28 10:42:57.503: E/AndroidRuntime(309): ... 21 more
01-28 10:42:57.503: E/AndroidRuntime(309): Caused by: java.lang.NullPointerException
01-28 10:42:57.503: E/AndroidRuntime(309): ... 25 more
Update : - New logcat Error
01-28 13:51:17.332: D/AndroidRuntime(766): Shutting down VM
01-28 13:51:17.332: W/dalvikvm(766): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-28 13:51:17.522: E/AndroidRuntime(766): FATAL EXCEPTION: main
01-28 13:51:17.522: E/AndroidRuntime(766): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.bank.us/com.bank.us.USActivity}: java.lang.ClassNotFoundException: com.bank.us.USActivity in loader dalvik.system.PathClassLoader[/data/app/com.bank.us-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.os.Looper.loop(Looper.java:123)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.reflect.Method.invoke(Method.java:521)
01-28 13:51:17.522: E/AndroidRuntime(766): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-28 13:51:17.522: E/AndroidRuntime(766): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-28 13:51:17.522: E/AndroidRuntime(766): at dalvik.system.NativeStart.main(Native Method)
01-28 13:51:17.522: E/AndroidRuntime(766): Caused by: java.lang.ClassNotFoundException: com.canadaqbank.usmle.USMLEActivity in loader dalvik.system.PathClassLoader[/data/app/com.canadaqbank.usmle-1.apk]
01-28 13:51:17.522: E/AndroidRuntime(766): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-28 13:51:17.522: E/AndroidRuntime(766): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-28 13:51:17.522: E/AndroidRuntime(766): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
01-28 13:51:17.522: E/AndroidRuntime(766): ... 11 more
If you are starting another project's activity then you can do it by this way:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName(
"com.abc.def.packname",
"com.abc.def.packname.MyActivity"));
startActivity(intent);

RuntimeException on AlertDialog.show()

I keep getting an exception when I want to display an alertdialog at the beginning of an activity.
I can't figure out why? I really would appreciate an explanation.
The code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if (!isInternetConnectionAvailable()) {
AlertDialog alert = new AlertDialog.Builder(getApplicationContext()).create();
alert.setMessage("TEST DIALOG!!!");
alert.show();
}
...
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): FATAL EXCEPTION: main
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.droidgroup.THMInfo/de.droidgroup.THMInfo.Activities.StartActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.os.Looper.loop(Looper.java:123)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at java.lang.reflect.Method.invoke(Method.java:521)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at dalvik.system.NativeStart.main(Native Method)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.view.ViewRoot.setView(ViewRoot.java:509)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.Dialog.show(Dialog.java:241)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at de.droidgroup.THMInfo.Activities.StartActivity.onCreate(StartActivity.java:82)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-19 16:04:33.933: ERROR/AndroidRuntime(15145): ... 11 more
Use this instead of getApplicationContext(). More info here.

Categories

Resources