My App crash rarely
i want to get off this bug for ever.
this is the log that users Report
i tried so long on this but nothing helps
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxx/com.xxx.xxx.Master_}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2097)
at android.app.ActivityThread.access$600(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4787)
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:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.xxx.xxx.HomeFragment.onActivityCreated(HomeFragment.java:140)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1508)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:958)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1097)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1895)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:566)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2045)
... 11 more
I want to set a button style programatically. This means without needing to define an xml file. I thought that by setting the background resource of the button with the predefined style IDs I could do this.
The line of code that fails is:
b1.setBackgroundResource(android.R.style.Widget_DeviceDefault_Light_Button_Borderless_Small);
There is an exception that states
android.content.res.Resources$NotFoundException: Resource ID #0x1030179.
What am I doing wrong?
EDIT:
I have tried to this:
Button b = new Button(context,null,android.R.style.Widget_DeviceDefault_Button_Borderless);
This no longer throws an exception but no real style is applied to the button. There is just text and there is no different states for when its pressed.
EDIT2:
Adding the original stack trace as requested:
03-03 08:17:58.810 5990-5990/legen.dary E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{legen.dary/legen.dary.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x103016c
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x103016c
at android.content.res.Resources.getValue(Resources.java:1013)
at android.content.res.Resources.getDrawable(Resources.java:658)
at android.view.View.setBackgroundResource(View.java:14179)
at legen.dary.TitleButtonView.<init>(TitleButtonView.java:24)
at legen.dary.MainActivity.onCreate(MainActivity.java:131)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I already generated API key by giving the MD5 fingureprint from here
https://code.google.com/apis/console/?noredirect#project:413913157166:access
but after running the android application i got error message Unfortunately,(ProjectName) has been stopped Android in the emulator
Need Help.. Thanks in advance
here is my logcat
t. Please make sure your kernel is compiled with file capabilities support enabled.
12-23 01:06:40.713: W/dalvikvm(1663): PR_CAPBSET_DROP 33 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
12-23 01:06:40.744: D/dalvikvm(1663): Not late-enabling CheckJNI (already on)
12-23 01:06:44.634: D/dalvikvm(1663): GC_FOR_ALLOC freed 243K, 11% free 2773K/3104K, paused 41ms, total 47ms
12-23 01:06:44.634: W/CursorWrapperInner(1663): Cursor finalized without prior close()
12-23 01:06:44.645: W/CursorWrapperInner(1663): Cursor finalized without prior close()
12-23 01:06:44.724: D/AndroidRuntime(1663): Shutting down VM
12-23 01:06:44.744: W/dalvikvm(1663): threadid=1: thread exiting with uncaught exception (group=0x41465700)
12-23 01:06:44.824: E/AndroidRuntime(1663): FATAL EXCEPTION: main
12-23 01:06:44.824: E/AndroidRuntime(1663): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.android.map.MapView
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.os.Looper.loop(Looper.java:137)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-23 01:06:44.824: E/AndroidRuntime(1663): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 01:06:44.824: E/AndroidRuntime(1663): at java.lang.reflect.Method.invoke(Method.java:525)
12-23 01:06:44.824: E/AndroidRuntime(1663): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-23 01:06:44.824: E/AndroidRuntime(1663): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-23 01:06:44.824: E/AndroidRuntime(1663): at dalvik.system.NativeStart.main(Native Method)
12-23 01:06:44.824: E/AndroidRuntime(1663): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.android.map.MapView
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-23 01:06:44.824: E/AndroidRuntime(1663): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.Activity.setContentView(Activity.java:1895)
12-23 01:06:44.824: E/AndroidRuntime(1663): at com.example.maps.MainActivity.onCreate(MainActivity.java:16)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.Activity.performCreate(Activity.java:5133)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-23 01:06:44.824: E/AndroidRuntime(1663): ... 11 more
12-23 01:06:44.824: E/AndroidRuntime(1663): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.map.MapView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.maps-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.maps-1, /vendor/lib, /system/lib]]
12-23 01:06:44.824: E/AndroidRuntime(1663): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-23 01:06:44.824: E/AndroidRuntime(1663): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-23 01:06:44.824: E/AndroidRuntime(1663): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
12-23 01:06:44.824: E/AndroidRuntime(1663): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
12-23 01:06:44.824: E/AndroidRuntime(1663): ... 21 more
12-23 01:06:54.994: I/Process(1663): Sending signal. PID: 1663 SIG: 9
12-23 01:08:58.434: D/dalvikvm(1820): GC_FOR_ALLOC freed 250K, 11% free 2766K/3104K, paused 67ms, total 76ms
12-23 01:08:58.434: W/CursorWrapperInner(1820): Cursor finalized without prior close()
12-23 01:08:58.464: W/CursorWrapperInner(1820): Cursor finalized without prior close()
12-23 01:08:58.624: D/AndroidRuntime(1820): Shutting down VM
12-23 01:08:58.624: W/dalvikvm(1820): threadid=1: thread exiting with uncaught exception (group=0x41465700)
12-23 01:08:58.714: E/AndroidRuntime(1820): FATAL EXCEPTION: main
12-23 01:08:58.714: E/AndroidRuntime(1820): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.android.map.MapView
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.os.Looper.loop(Looper.java:137)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-23 01:08:58.714: E/AndroidRuntime(1820): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 01:08:58.714: E/AndroidRuntime(1820): at java.lang.reflect.Method.invoke(Method.java:525)
12-23 01:08:58.714: E/AndroidRuntime(1820): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-23 01:08:58.714: E/AndroidRuntime(1820): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-23 01:08:58.714: E/AndroidRuntime(1820): at dalvik.system.NativeStart.main(Native Method)
12-23 01:08:58.714: E/AndroidRuntime(1820): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.google.android.map.MapView
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-23 01:08:58.714: E/AndroidRuntime(1820): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.Activity.setContentView(Activity.java:1895)
12-23 01:08:58.714: E/AndroidRuntime(1820): at com.example.maps.MainActivity.onCreate(MainActivity.java:16)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.Activity.performCreate(Activity.java:5133)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-23 01:08:58.714: E/AndroidRuntime(1820): ... 11 more
12-23 01:08:58.714: E/AndroidRuntime(1820): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.map.MapView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.maps-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.maps-2, /vendor/lib, /system/lib]]
12-23 01:08:58.714: E/AndroidRuntime(1820): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-23 01:08:58.714: E/AndroidRuntime(1820): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-23 01:08:58.714: E/AndroidRuntime(1820): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
12-23 01:08:58.714: E/AndroidRuntime(1820): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
12-23 01:08:58.714: E/AndroidRuntime(1820): ... 21 more
12-23 01:09:10.654: I/Process(1820): Sending signal. PID: 1820 SIG: 9
12-23 01:16:40.084: D/dalvikvm(1913): GC_FOR_ALLOC freed 229K, 11% free 2786K/3104K, paused 47ms, total 52ms
12-23 01:16:40.084: W/CursorWrapperInner(1913): Cursor finalized without prior close()
12-23 01:16:40.095: W/CursorWrapperInner(1913): Cursor finalized without prior close()
12-23 01:16:40.114: D/AndroidRuntime(1913): Shutting down VM
12-23 01:16:40.114: W/dalvikvm(1913): threadid=1: thread exiting with uncaught exception (group=0x41465700)
12-23 01:16:40.146: E/AndroidRuntime(1913): FATAL EXCEPTION: main
12-23 01:16:40.146: E/AndroidRuntime(1913): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class activity
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.os.Looper.loop(Looper.java:137)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-23 01:16:40.146: E/AndroidRuntime(1913): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 01:16:40.146: E/AndroidRuntime(1913): at java.lang.reflect.Method.invoke(Method.java:525)
12-23 01:16:40.146: E/AndroidRuntime(1913): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-23 01:16:40.146: E/AndroidRuntime(1913): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-23 01:16:40.146: E/AndroidRuntime(1913): at dalvik.system.NativeStart.main(Native Method)
12-23 01:16:40.146: E/AndroidRuntime(1913): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class activity
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-23 01:16:40.146: E/AndroidRuntime(1913): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.Activity.setContentView(Activity.java:1895)
12-23 01:16:40.146: E/AndroidRuntime(1913): at com.example.maps.MainActivity.onCreate(MainActivity.java:16)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.Activity.performCreate(Activity.java:5133)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-23 01:16:40.146: E/AndroidRuntime(1913): ... 11 more
12-23 01:16:40.146: E/AndroidRuntime(1913): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.activity" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.maps-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.maps-1, /vendor/lib, /system/lib]]
12-23 01:16:40.146: E/AndroidRuntime(1913): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-23 01:16:40.146: E/AndroidRuntime(1913): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-23 01:16:40.146: E/AndroidRuntime(1913): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
12-23 01:16:40.146: E/AndroidRuntime(1913): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
12-23 01:16:40.146: E/AndroidRuntime(1913): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
12-23 01:16:40.146: E/AndroidRuntime(1913): ... 21 more
12-23 01:16:46.515: I/Process(1913): Sending signal. PID: 1913 SIG: 9
12-23 01:25:04.063: D/dalvikvm(1967): GC_FOR_ALLOC freed 232K, 11% free 2784K/3104K, paused 30ms, total 36ms
12-23 01:25:04.063: W/CursorWrapperInner(1967): Cursor finalized without prior close()
12-23 01:25:04.073: W/CursorWrapperInner(1967): Cursor finalized without prior close()
12-23 01:25:04.093: D/AndroidRuntime(1967): Shutting down VM
12-23 01:25:04.093: W/dalvikvm(1967): threadid=1: thread exiting with uncaught exception (group=0x41465700)
12-23 01:25:04.103: E/AndroidRuntime(1967): FATAL EXCEPTION: main
12-23 01:25:04.103: E/AndroidRuntime(1967): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class com.google.android.map.MapView
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.os.Looper.loop(Looper.java:137)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-23 01:25:04.103: E/AndroidRuntime(1967): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 01:25:04.103: E/AndroidRuntime(1967): at java.lang.reflect.Method.invoke(Method.java:525)
12-23 01:25:04.103: E/AndroidRuntime(1967): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-23 01:25:04.103: E/AndroidRuntime(1967): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-23 01:25:04.103: E/AndroidRuntime(1967): at dalvik.system.NativeStart.main(Native Method)
12-23 01:25:04.103: E/AndroidRuntime(1967): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.google.android.map.MapView
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-23 01:25:04.103: E/AndroidRuntime(1967): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.Activity.setContentView(Activity.java:1895)
12-23 01:25:04.103: E/AndroidRuntime(1967): at com.example.maps.MainActivity.onCreate(MainActivity.java:16)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.Activity.performCreate(Activity.java:5133)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-23 01:25:04.103: E/AndroidRuntime(1967): ... 11 more
12-23 01:25:04.103: E/AndroidRuntime(1967): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.map.MapView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.maps-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.maps-2, /vendor/lib, /system/lib]]
12-23 01:25:04.103: E/AndroidRuntime(1967): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-23 01:25:04.103: E/AndroidRuntime(1967): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-23 01:25:04.103: E/AndroidRuntime(1967): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
12-23 01:25:04.103: E/AndroidRuntime(1967): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
12-23 01:25:04.103: E/AndroidRuntime(1967): ... 21 more
12-23 01:25:22.094: I/Process(1967): Sending signal. PID: 1967 SIG: 9
12-23 01:27:40.973: D/dalvikvm(2025): GC_FOR_ALLOC freed 233K, 11% free 2783K/3104K, paused 32ms, total 38ms
12-23 01:27:40.973: W/CursorWrapperInner(2025): Cursor finalized without prior close()
12-23 01:27:40.973: W/CursorWrapperInner(2025): Cursor finalized without prior close()
12-23 01:27:41.003: D/AndroidRuntime(2025): Shutting down VM
12-23 01:27:41.003: W/dalvikvm(2025): threadid=1: thread exiting with uncaught exception (group=0x41465700)
12-23 01:27:41.023: E/AndroidRuntime(2025): FATAL EXCEPTION: main
12-23 01:27:41.023: E/AndroidRuntime(2025): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class com.google.android.map.MapView
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.os.Looper.loop(Looper.java:137)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-23 01:27:41.023: E/AndroidRuntime(2025): at java.lang.reflect.Method.invokeNative(Native Method)
12-23 01:27:41.023: E/AndroidRuntime(2025): at java.lang.reflect.Method.invoke(Method.java:525)
12-23 01:27:41.023: E/AndroidRuntime(2025): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-23 01:27:41.023: E/AndroidRuntime(2025): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-23 01:27:41.023: E/AndroidRuntime(2025): at dalvik.system.NativeStart.main(Native Method)
12-23 01:27:41.023: E/AndroidRuntime(2025): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.google.android.map.MapView
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-23 01:27:41.023: E/AndroidRuntime(2025): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.Activity.setContentView(Activity.java:1895)
12-23 01:27:41.023: E/AndroidRuntime(2025): at com.example.maps.MainActivity.onCreate(MainActivity.java:16)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.Activity.performCreate(Activity.java:5133)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-23 01:27:41.023: E/AndroidRuntime(2025): ... 11 more
12-23 01:27:41.023: E/AndroidRuntime(2025): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.map.MapView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.maps-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.maps-1, /vendor/lib, /system/lib]]
12-23 01:27:41.023: E/AndroidRuntime(2025): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
12-23 01:27:41.023: E/AndroidRuntime(2025): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-23 01:27:41.023: E/AndroidRuntime(2025): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
12-23 01:27:41.023: E/AndroidRuntime(2025): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
12-23 01:27:41.023: E/AndroidRuntime(2025): ... 21 more
12-23 01:32:41.724: I/Process(2025): Sending signal. PID: 2025 SIG: 9
HERE IS MY MANIFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name ="com.google.android.maps"/>
<activity
android:name="com.example.maps.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
</i>
HERE IS MY ACTIVITY CLASS
package com.example.maps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends MapActivity {
MapView map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = (MapView)findViewById(R.id.mvMainActivity);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
HERE IS MY XML->LAYOUT FILE
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.google.android.map.MapView
android:id = "#+id/mvMainActivity"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:clickable="true"
android:apiKey = "AIzaSyBq4zldj_kQVdwGt9ru-nWSSOJ0ORUBuFE"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
I would recommend you update the ADK's libraries. This question's answer details how to update your libraries.
Furthermore, verify that the libraries you imported for com.google.android.maps have been added to your build path. It seems an off thing to check but working with Android, I have seen many stranger things!
Edit: As stated by one of the comments, the deprecated maps library might be the culprit. If the update does not fix the problem. Try raising the minimum version you are targeting. Legacy support is nice but often induces more problems than it solves. Unless it is of crucial importance to you, I would personally only target the latest release which I believe was API version 14 or 16.
yup as Raghunandan said you are using Google maps API V1 which is deprecated one. Follow this link for Convert it to API V2.
And also you can try this code which I got map on my emulator.
I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}
I have been trying to add a map to my application, I have followed instructions on the android developers HelloGoogleMaps tutorial but my map is just force closing when I run the maps option. I have obtained my api key logged permissions in manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MappDemo.mymaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:debuggable="true" >
<activity
android:name=".MappingDemoActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<uses-library android:name="com.google.android.maps" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ShowTheMap" android:label="Lat/Long Location"> </activity>
<activity android:name=".MapMe" android:label="Track Present Location"> </activity>
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</application>
</manifest>
Can some one tell if any thing needs to be configured in addition to run the code?
03-25 11:50:52.217: I/Process(687): Sending signal. PID: 687 SIG: 9
03-25 11:51:00.557: D/AndroidRuntime(729): Shutting down VM
03-25 11:51:00.567: W/dalvikvm(729): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-25 11:51:00.627: E/AndroidRuntime(729): FATAL EXCEPTION: main
03-25 11:51:00.627: E/AndroidRuntime(729): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MappDemo.mymaps/com.MappDemo.mymaps.MappingDemoActivity}: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.os.Looper.loop(Looper.java:123)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-25 11:51:00.627: E/AndroidRuntime(729): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 11:51:00.627: E/AndroidRuntime(729): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 11:51:00.627: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-25 11:51:00.627: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-25 11:51:00.627: E/AndroidRuntime(729): at dalvik.system.NativeStart.main(Native Method)
03-25 11:51:00.627: E/AndroidRuntime(729): Caused by: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:51:00.627: E/AndroidRuntime(729): at com.MappDemo.mymaps.MappingDemoActivity.onCreate(MappingDemoActivity.java:19)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 11:51:00.627: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-25 11:51:00.627: E/AndroidRuntime(729): ... 11 more
03-25 11:51:10.013: I/Process(729): Sending signal. PID: 729 SIG: 9
03-25 11:52:16.817: D/AndroidRuntime(782): Shutting down VM
03-25 11:52:16.817: W/dalvikvm(782): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-25 11:52:16.877: E/AndroidRuntime(782): FATAL EXCEPTION: main
03-25 11:52:16.877: E/AndroidRuntime(782): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MappDemo.mymaps/com.MappDemo.mymaps.MappingDemoActivity}: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.os.Looper.loop(Looper.java:123)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-25 11:52:16.877: E/AndroidRuntime(782): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 11:52:16.877: E/AndroidRuntime(782): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 11:52:16.877: E/AndroidRuntime(782): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-25 11:52:16.877: E/AndroidRuntime(782): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-25 11:52:16.877: E/AndroidRuntime(782): at dalvik.system.NativeStart.main(Native Method)
03-25 11:52:16.877: E/AndroidRuntime(782): Caused by: java.lang.ClassCastException: com.MappDemo.mymaps.MappingDemoActivity
03-25 11:52:16.877: E/AndroidRuntime(782): at com.MappDemo.mymaps.MappingDemoActivity.onCreate(MappingDemoActivity.java:19)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 11:52:16.877: E/AndroidRuntime(782): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-25 11:52:16.877: E/AndroidRuntime(782): ... 11 more
this is what I can see in logcat..
this what I have in mappingDemoActivity.java
public class MappingDemoActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//add listners for all buttons
View firstbutton= findViewById(R.id.geocode_button);
firstbutton.setOnClickListener((OnClickListener) this);
View secondButton = findViewById(R.id.latlong_button);
secondButton.setOnClickListener((OnClickListener) this);
View thirdButton = findViewById(R.id.presentLocation_button);
thirdButton.setOnClickListener((OnClickListener) this);
}
public void onClick(View v)
{
switch(v.getId())
{
case R.id.geocode_button:
Log.i("Button","Button 1 pushed");
Intent j = new Intent(this, ShowTheMap.class);
startActivity(j);
break;
case R.id.latlong_button:
Log.i("Button","Button 2 pushed");
Intent k = new Intent(this, ShowTheMap.class);
startActivity(k);
break;
case R.id.presentLocation_button:
Log.i("Button","Button 3 pushed");
Intent m = new Intent(this, MapMe.class);
startActivity(m);
break;
}
}
<uses-permission> tag needs to be a child of <manifest>, not <application>.
Try change <uses-permission> position, it can help.
Remove this code which is inside <intent-filter>
`<uses-library android:name="com.google.android.maps" />`
Because it is Already there in Below Quote.
Have a look at the Google MapsDemo that is included in the SDK my path is:
C:\android-sdk\add-ons\addon-google_apis-google_inc_-10\samples\MapsDemo
I had a quite anoying problem (MapActivity crashes on some devices) that was only showing up on certain(!) Android devices and also not in the Emulator. What I did was, to strip down the working demo until it was similar to my basic example. Then it turned out that Samsung phones don't accept package names not starting with com., while other devices (HTC Flyer) do! But this is not your problem, since you are using a com. package name.
There might be one more thing that comes to my mind. You didn't post your main.xml. If you use a nested LinearLayout below the MapView this also crashes the app. On top of the MapView it works fine. So in case you are using something like:
<LinearLayout ... >
<com.google.android.maps.MapView ... />
<LinearLayout ... >
<Button .../>
</LinearLayout>
</LinearLayout>
This could cause your problem. This is reproducable and throws exactly the same java.lang.ClassCastException error.
Also be sure to have your < uses-permission > and < uses-library > statements in the right place, as the guys said before. The first one must be a direct child of the < manifest > node. The second one must be a direct child of the < application > node.
I hope this helps you. I was going crazy with this stuff.
Bernd