When i run my java code in the emulator or the real device, i every once in a while get this error. However, the app goes on and installs well. Since the error below appears in red text in my eclipse log, i have been forced to ask.. Is it an error that can cause significant problems when i release the app eventually or its something i should ignore? My guess is that i can use a try catch statement to capture the NullPointerException but i have no clue at what point in my MainActivity this error is generated.
12-10 20:15:44.268: E/AndroidRuntime(1126): FATAL EXCEPTION: main
12-10 20:15:44.268: E/AndroidRuntime(1126): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4124)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.os.Looper.loop(Looper.java:137)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-10 20:15:44.268: E/AndroidRuntime(1126): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 20:15:44.268: E/AndroidRuntime(1126): at java.lang.reflect.Method.invoke(Method.java:511)
12-10 20:15:44.268: E/AndroidRuntime(1126): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-10 20:15:44.268: E/AndroidRuntime(1126): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-10 20:15:44.268: E/AndroidRuntime(1126): at dalvik.system.NativeStart.main(Native Method)
12-10 20:15:44.268: E/AndroidRuntime(1126): Caused by: java.lang.NullPointerException
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.getClassLoader(LoadedApk.java:320)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.makeApplication(LoadedApk.java:493)
12-10 20:15:44.268: E/AndroidRuntime(1126): ... 11 more
Related
I was following GCM Tutorial and I took utmost care in making no mistake and implementing same code in my project. But when I run the project I am getting ClassCast exception. I thought I would have missed something so I downloaded the source from that post and copied each and every line carefully in my project but still I am getting same exception. Please help solve the error.
12-10 23:41:25.812: E/AndroidRuntime(9549): FATAL EXCEPTION: main
12-10 23:41:25.812: E/AndroidRuntime(9549): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exaple.oldgcm/com.exaple.oldgcm.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.exaple.oldgcm.Controller
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.access$600(ActivityThread.java:128)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.os.Looper.loop(Looper.java:137)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.main(ActivityThread.java:4517)
12-10 23:41:25.812: E/AndroidRuntime(9549): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 23:41:25.812: E/AndroidRuntime(9549): at java.lang.reflect.Method.invoke(Method.java:511)
12-10 23:41:25.812: E/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
12-10 23:41:25.812: E/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
12-10 23:41:25.812: E/AndroidRuntime(9549): at dalvik.system.NativeStart.main(Native Method)
12-10 23:41:25.812: E/AndroidRuntime(9549): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.exaple.oldgcm.Controller
12-10 23:41:25.812: E/AndroidRuntime(9549): at com.exaple.oldgcm.MainActivity.onCreate(MainActivity.java:33)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.Activity.performCreate(Activity.java:4470)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
12-10 23:41:25.812: E/AndroidRuntime(9549): ... 11 more
I believe the problem is that you haven't set an Application name in your manifest.
Refer to this solution:
android classcastexception at android.app.Application
I have used ZBAR library to scan bar code in my Application.
And I got this error log while opening camera on Samsung Galaxy S3 :
java.lang.RuntimeException: startPreview failed
at android.hardware.Camera.startPreview(Native Method)
at com.SGID.MainApp.ScanningFragment.engageCamera(ScanningFragment.java:184)
at com.SGID.MainApp.ScanningFragment.access$10(ScanningFragment.java:154)
at com.SGID.MainApp.ScanningFragment$4.run(ScanningFragment.java:111)
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:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.SGID.MainApp/com.SGID.MainApp.AllTabsActivity}
: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.SGID.MainApp.ParametersFragment.onCreateView(ParametersFragment.java:78)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1167)
at android.app.Activity.performStart(Activity.java:5216)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
... 11 more
EDIT :
Getting error at this line :
CameraPreview mPreview = new CameraPreview(getActivity(), mCamera, previewCb,
autoFocusCB);
Can Anyone help me to resolve this error??
Thanks in advance..
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));
}
My android is W806 with MIUI system(andrid 2.3.4, could be downloaded at
http://119.147.150.88/gdown_group321/M00/01/BB/d5OWWE-TiE0AAAAABFRc6HZ-Izc1688998/MIUI_W806_updateEX.zip?k=rscjHEFnZBVxNvfDqVP3Iw&t=1355119512&u=712526008-27587528-bjpdc2a8&s=51200&file=MIUI_W806_updateEX.zip
)
I follow this example: http://mirnauman.wordpress.com/2012/01/30/using-google-maps-in-android-development-tutorial-part-1/, I have chosen Google API of 2.3.3 downloaded from SDK manager. But I got the problem Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY.
I try to search solutions in google and stackoverflow, but no one fits me...I have some logcat, and here it is:
12-10 16:38:19.820: W/dalvikvm(5906): Unable to resolve superclass of Lcom/example/googlemapapp/GooglemapsActivity; (463)
12-10 16:38:19.820: W/dalvikvm(5906): Link of class 'Lcom/example/googlemapapp/GooglemapsActivity;' failed
12-10 16:38:19.820: D/AndroidRuntime(5906): Shutting down VM
12-10 16:38:19.820: W/dalvikvm(5906): threadid=1: thread exiting with uncaught exception (group=0x4011b560)
12-10 16:38:19.830: E/AndroidRuntime(5906): FATAL EXCEPTION: main
12-10 16:38:19.830: E/AndroidRuntime(5906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.googlemapapp/com.example.googlemapapp.GooglemapsActivity}: java.lang.ClassNotFoundException: com.example.googlemapapp.GooglemapsActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.googlemapapp-1.apk]
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.os.Looper.loop(Looper.java:130)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.main(ActivityThread.java:3684)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.reflect.Method.invoke(Method.java:507)
12-10 16:38:19.830: E/AndroidRuntime(5906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-10 16:38:19.830: E/AndroidRuntime(5906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-10 16:38:19.830: E/AndroidRuntime(5906): at dalvik.system.NativeStart.main(Native Method)
12-10 16:38:19.830: E/AndroidRuntime(5906): Caused by: java.lang.ClassNotFoundException: com.example.googlemapapp.GooglemapsActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.googlemapapp-1.apk]
12-10 16:38:19.830: E/AndroidRuntime(5906): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
12-10 16:38:19.830: E/AndroidRuntime(5906): ... 11 more
Looks like you are missing some information in your android project files and/or AndroidManifest.xml ?
Try and look at my earlier answer to a somewhat similar answers:
1. Answer
2. Answer
I can't find following error in my code. It looks like the problem is in the asynctask onpostexecute.
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:672)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:368)
at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:160)
at android.app.Dialog.dismissDialog(Dialog.java:319)
at android.app.Dialog.dismiss(Dialog.java:302)
at www.mobilezar.mn.Advertisements$InitialLoading.onPostExecute(Advertisements.java:216)
at www.mobilezar.mn.Advertisements$InitialLoading.onPostExecute(Advertisements.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)