I am having a little trouble. I am completely new at this. I am trying to get my app to start with a splash screen then continue on to a new activity, but my app keeps force closing with a fatal exception:main. this is the logcat
02-12 02:56:32.989: D/AndroidRuntime(1487): Shutting down VM
02-12 02:56:32.989: W/dalvikvm(1487): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
02-12 02:56:33.009: E/AndroidRuntime(1487): FATAL EXCEPTION: main
02-12 02:56:33.009: E/AndroidRuntime(1487): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.madonk.LAFEST/com.madonk.LAFEST.MAIN}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1702)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1722)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.ActivityThread.access$1500(ActivityThread.java:124)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.os.Looper.loop(Looper.java:130)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.ActivityThread.main(ActivityThread.java:3821)
02-12 02:56:33.009: E/AndroidRuntime(1487): at java.lang.reflect.Method.invokeNative(Native Method)
02-12 02:56:33.009: E/AndroidRuntime(1487): at java.lang.reflect.Method.invoke(Method.java:507)
02-12 02:56:33.009: E/AndroidRuntime(1487): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-12 02:56:33.009: E/AndroidRuntime(1487): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-12 02:56:33.009: E/AndroidRuntime(1487): at dalvik.system.NativeStart.main(Native Method)
02-12 02:56:33.009: E/AndroidRuntime(1487): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.ListActivity.onContentChanged(ListActivity.java:243)
02-12 02:56:33.009: E/AndroidRuntime(1487): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.Activity.setContentView(Activity.java:1716)
02-12 02:56:33.009: E/AndroidRuntime(1487): at com.madonk.LAFEST.MAIN.onCreate(MAIN.java:17)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-12 02:56:33.009: E/AndroidRuntime(1487): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
02-12 02:56:33.009: E/AndroidRuntime(1487): ... 11 more
If there is anything anyone can do to help, I would greatly appreciate it.
Your activity probably extends ListActivity and because of this in your xml file containing the layout of your activity(the one you set with setContentView(R.layout.name_of_layout)) you must have a ListView element with the id:
<ListView android:id="#android:id/list"
//other attributes
>
Related
So, I am going through the Tutorial #12 and everything is working fine. I then try to go onto Tutorial #13 for Saving/Restoring Last-Read Position and the app crashes:
04-10 15:59:26.510: E/Trace(704): error opening trace file: No such file or directory (2)
04-10 15:59:27.491: D/AndroidRuntime(704): Shutting down VM
04-10 15:59:27.491: W/dalvikvm(704): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
04-10 15:59:27.500: E/AndroidRuntime(704): FATAL EXCEPTION: main
04-10 15:59:27.500: E/AndroidRuntime(704): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.commonsware.empublite/com.commonsware.empublite.EmPubLiteActivity}: java.lang.NullPointerException
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.os.Looper.loop(Looper.java:137)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-10 15:59:27.500: E/AndroidRuntime(704): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 15:59:27.500: E/AndroidRuntime(704): at java.lang.reflect.Method.invoke(Method.java:511)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-10 15:59:27.500: E/AndroidRuntime(704): at dalvik.system.NativeStart.main(Native Method)
04-10 15:59:27.500: E/AndroidRuntime(704): Caused by: java.lang.NullPointerException
04-10 15:59:27.500: E/AndroidRuntime(704): at com.commonsware.empublite.ModelFragment.executeAsyncTask(ModelFragment.java:51)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.commonsware.empublite.ModelFragment.deliverModel(ModelFragment.java:38)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.commonsware.empublite.ModelFragment.onActivityCreated(ModelFragment.java:29)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:891)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:505)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.Activity.performStart(Activity.java:5018)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
04-10 15:59:27.500: E/AndroidRuntime(704): ... 11 more
I tried to comment out the code I did until the last point that it was working, but that didn't seem to work. I am not really sure how to read this stack trace either. What should I be looking at to fix this problem?
Thanks.
I am not really sure how to read this stack trace either. What should I be looking at to fix this problem?
Line 51 of ModelFragment.java, in the executeAsyncTask() method is where you are crashing (see last stack trace stanza, starting with Caused by: java.lang.NullPointerException).
Your line numbers and those in the answers are not completely lining up. However, the only way executeAsyncTask() could have a NullPointerException is if the AsyncTask you are passing in is null, and that should not be possible as you define those tasks immediately before calling executeAsyncTask() in the deliverModel() method. Perhaps you missed a line in deliverModel().
Here is what I am doing
ImageView image2 = (ImageView) findViewById(R.id.imageView3);
image2.getDrawable().setCallback(null);
image2.setImageResource(R.drawable.fire);
where fire is an xml file proposing an animation drawable
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="#drawable/fire1" android:duration="50" />
<item android:drawable="#drawable/fire2" android:duration="50" />
<item android:drawable="#drawable/fire3" android:duration="50" />
<item android:drawable="#drawable/fire4" android:duration="50" />
<item android:drawable="#drawable/fire5" android:duration="50" />
...
<item android:drawable="#drawable/fire16" android:duration="50" />
I have this error
02-12 11:37:20.919: E/dalvikvm-heap(3193): 1535664-byte external allocation too large for this process.
02-12 11:37:20.959: E/GraphicsJNI(3193): VM won't let us allocate 1535664 bytes
02-12 11:37:20.959: W/dalvikvm(3193): threadid=1: thread exiting with uncaught exception (group=0x40018560)
02-12 11:37:20.979: E/AndroidRuntime(3193): FATAL EXCEPTION: main
02-12 11:37:20.979: E/AndroidRuntime(3193): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.content.res.Resources.getDrawable(Resources.java:581)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:267)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.content.res.Resources.loadDrawable(Resources.java:1694)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.content.res.Resources.getDrawable(Resources.java:581)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.widget.ImageView.resolveUri(ImageView.java:501)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.widget.ImageView.setImageResource(ImageView.java:280)
02-12 11:37:20.979: E/AndroidRuntime(3193): at com.example.kersplatt.GameActivity.onCreate(GameActivity.java:71)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.os.Looper.loop(Looper.java:130)
02-12 11:37:20.979: E/AndroidRuntime(3193): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-12 11:37:20.979: E/AndroidRuntime(3193): at java.lang.reflect.Method.invokeNative(Native Method)
02-12 11:37:20.979: E/AndroidRuntime(3193): at java.lang.reflect.Method.invoke(Method.java:507)
02-12 11:37:20.979: E/AndroidRuntime(3193): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
02-12 11:37:20.979: E/AndroidRuntime(3193): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
02-12 11:37:20.979: E/AndroidRuntime(3193): at dalvik.system.NativeStart.main(Native Method)
I read so many threads about memory leaks, memory errors (for instance java.lang.OutOfMemoryError: bitmap size exceeds VM budget - Android) but I didn't succeed in solving my problem
When I remplace image2.setImageResource(R.drawable.fire); by image2.setImageResource(R.drawable.fire1); where fire1 is a simple png, everything works fine
What could I do to solve my problem
To remove OutOfMemory error, you should focus on scaling. You can find at http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
For reasons with which I won't bore you, I have to change development computers, and for the life of me I can't get my project to work on the second machine.
I have one library which is a .jar file which both machine have access to. But the program works fine on machine A but on machine B I get the errors below. At first I thought check the manifest, but, exactly the same project works fine on Machine A. So it must be something wrong with my development environment on B. Right? I can't think what it might be. I've got more apis on B than A.
04-10 20:21:50.826: W/dalvikvm(1487): Unable to resolve superclass of Lcom/webs/thefineanimationemporium/BoxingTmcthreeActivity; (117)
04-10 20:21:50.826: W/dalvikvm(1487): Link of class 'Lcom/webs/thefineanimationemporium/BoxingTmcthreeActivity;' failed
04-10 20:21:50.826: D/AndroidRuntime(1487): Shutting down VM
04-10 20:21:50.826: W/dalvikvm(1487): threadid=1: thread exiting with uncaught exception (group=0x2aac8578)
04-10 20:21:50.856: E/AndroidRuntime(1487): FATAL EXCEPTION: main
04-10 20:21:50.856: E/AndroidRuntime(1487): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.webs.thefineanimationemporium/com.webs.thefineanimationemporium.BoxingTmc threeActivity}: java.lang.ClassNotFoundException: com.webs.thefineanimationemporium.BoxingTmcthreeActivity in loader dalvik.system.PathClassLoader[/data/app/com.webs.thefineanimationemporium-1.apk]
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1581)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.os.Looper.loop(Looper.java:138)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.app.ActivityThread.main(ActivityThread.java:3701)
04-10 20:21:50.856: E/AndroidRuntime(1487): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 20:21:50.856: E/AndroidRuntime(1487): at java.lang.reflect.Method.invoke(Method.java:507)
04-10 20:21:50.856: E/AndroidRuntime(1487): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
04-10 20:21:50.856: E/AndroidRuntime(1487): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
04-10 20:21:50.856: E/AndroidRuntime(1487): at dalvik.system.NativeStart.main(Native Method)
04-10 20:21:50.856: E/AndroidRuntime(1487): Caused by: java.lang.ClassNotFoundException: com.webs.thefineanimationemporium.BoxingTmcthreeActivity in loader dalvik.system.PathClassLoader[/data/app/com.webs.thefineanimationemporium-1.apk]
04-10 20:21:50.856: E/AndroidRuntime(1487): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-10 20:21:50.856: E/AndroidRuntime(1487): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-10 20:21:50.856: E/AndroidRuntime(1487): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-10 20:21:50.856: E/AndroidRuntime(1487): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
04-10 20:21:50.856: E/AndroidRuntime(1487): ... 11 more
04-10 20:21:55.216: I/Process(1487): Sending signal. PID: 1487 SIG: 9
Sounds like a dodgy install on the second device to me, since one of the classes being called cant be found. Have you tried reinstalling?
edit: Sorry for sounding like someone from a tech support line...
These error messages appear when I run my Application. It doesn't affect the execution of the application though. The app is based on Android 4 ( API Level 14), it has some code to call a web service, and the build path has http-commons library.
02-12 10:39:11.110: E/AndroidRuntime(661): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3909)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.ActivityThread.access$1300(ActivityThread.java:122)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1184)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.os.Looper.loop(Looper.java:137)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.ActivityThread.main(ActivityThread.java:4340)
02-12 10:39:11.110: E/AndroidRuntime(661): at java.lang.reflect.Method.invokeNative(Native Method )
02-12 10:39:11.110: E/AndroidRuntime(661): at java.lang.reflect.Method.invoke(Method.java:511)
02-12 10:39:11.110: E/AndroidRuntime(661): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-12 10:39:11.110: E/AndroidRuntime(661): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-12 10:39:11.110: E/AndroidRuntime(661): at dalvik.system.NativeStart.main(Native Method)
02-12 10:39:11.110: E/AndroidRuntime(661): Caused by: java.lang.NullPointerException
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
02-12 10:39:11.110: E/AndroidRuntime(661): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
02-12 10:39:11.110: E/AndroidRuntime(661): ... 11 more
If you google for initializeJavaContextClassLoader NullPointerException you'll find you are definitely not the only one running into this. The solution isn't really clear though.
Have you tried doing a Project -> Clean and rebuilding?
Ive follow the tutoria about how to make activity Gallery on [android-developer][1]
[1]: http://developer.android.com/guide/tutorials/views/hello-gallery.html but i got the next error:
02-12 17:54:06.221: ERROR/AndroidRuntime(1330): Uncaught handler: thread main exiting due to uncaught exception
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.addsensor.CameraMap/com.addsensor.CameraMap.GalleryCamera}: java.lang.NullPointerException
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.os.Looper.loop(Looper.java:123)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.app.ActivityThread.main(ActivityThread.java:3948)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at java.lang.reflect.Method.invokeNative(Native Method)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at java.lang.reflect.Method.invoke(Method.java:521)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at dalvik.system.NativeStart.main(Native Method)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): Caused by: java.lang.NullPointerException
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at com.addsensor.CameraMap.GalleryCamera.onCreate(GalleryCamera.java:20)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
02-12 17:54:06.301: ERROR/AndroidRuntime(1330): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
I have also change one thing which someone comment here, on [stackoverflow][1]
[1]: Android Hello, Gallery tutorial -- "R.styleable cannot be resolved" but i am still getting the error. Its a simple activity and i dont know how to follow. Anyone knows?¿ or how to fix it?¿
thanks
You are trying to use a reference to null (e.g. variable uninitialized, etc..) in CameraMap.GalleryCamera,onCreate() method, line 20.
Please post code for this method (and indicate line number 20).