Sudden app shutdown without doing any activity, throws IllegalStateException onMeasure() - java

My app always shutdown in random time interval (mostly from few minutes to something like 20 mins). The "App stopped working" messagebox appears. Biggest problem is, I don't do anything in app (like interacting with it), and it just random shutdown by itself. Here's logcat print:
07-15 20:34:16.595 27361-27363/test.game D/dalvikvm: GC_CONCURRENT freed 141
9K, 44% free 13902K/24391K, paused 4ms+9ms, total 66ms
07-15 20:34:28.997 27361-27363/test.game D/dalvikvm: GC_CONCURRENT freed 1416K, 43% free 13903K/24391K, paused 3ms+7ms, total 56ms
07-15 20:34:29.418 27361-27361/test.game D/AndroidRuntime: Shutting down VM
07-15 20:34:29.418 27361-27361/test.game W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x412b52a0)
07-15 20:34:29.498 27361-27361/test.game E/AndroidRuntime: FATAL EXCEPTION: main java.lang.IllegalStateException: onMeasure() did not set the measured dimension by calling setMeasuredDimension()
at android.view.View.measure(View.java:15293)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15288)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2397)
at android.view.View.measure(View.java:15288)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
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:4867)
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:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
One would say, it's because I didn't write setMeasuredDimension() when overriding method onMeasure(). Also, docs say you have to write this line to your onMeasure, otherwise the IllegalStateException will be thrown (see it here).
But I don't overriding onMeasure anywhere in my whole project, so problem is not here (at least not on my side in this case).
Few things to note:
this is full logcat log, and any of these lines ("at android. ...") doesn't link to my code, all goes to source - that means all of these links are gray
this exception always happens only on my S3 Mini (android 4.1.2), but never happened on my old Galaxy Ace S5830i (android 2.3.6) (and yes, I tested it alot - over 20hours on old phone and app still running!).
never happened in emulator
there are no "view resizing" operations running in background, which could cause this exception
I would like to post some code, but I have absolutely no idea where this exception could be thrown.
If someone can help, I'd be really, really grateful. I'm lost at this point...

Since there is not code, this is just a random guess. You can start by looking out for activities in which you've added fragments. It might be that the activity containing a fragment has been destroyed on the device due to inactivity for a long time(and memory requirements by the system, which I think is the reason that you are finding the bug on a device and not on the other). So the case is that the fragment might be referring to a view which might not be attached to the window now. (You can also look for views that use fragment adapters like viewPager, etc if you have used them).

Related

Sudden shutdown with IllegalStateException without doing anything

After 26 minutes leaving my app running without doing anything with it as a user, "app has stopped" window suddenly pop up and Logcat prints only this:
07-15 20:34:16.595 27361-27363/test.game D/dalvikvm: GC_CONCURRENT freed 1419K, 44% free 13902K/24391K, paused 4ms+9ms, total 66ms
07-15 20:34:28.997 27361-27363/test.game D/dalvikvm: GC_CONCURRENT freed 1416K, 43% free 13903K/24391K, paused 3ms+7ms, total 56ms
07-15 20:34:29.418 27361-27361/test.game D/AndroidRuntime: Shutting down VM
07-15 20:34:29.418 27361-27361/test.game W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x412b52a0)
07-15 20:34:29.498 27361-27361/test.game E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.IllegalStateException: onMeasure() did not set the measured dimension by calling setMeasuredDimension()
at android.view.View.measure(View.java:15293)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15288)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2397)
at android.view.View.measure(View.java:15288)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
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:4867)
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:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Any ideas where could be problem? It happened now for 2nd time (1st time it happened slightly sooner, in about ~13 mins), so it's not some "random" issue.
I can't provide any sample code since none of the Logcat errors links to my code (all goes to the source of specific View). Another strange behaviour is, this happened twice on my S3 Mini (in mentioned 13 and 26 mins), but didn't happened yet on my old Ace S5830i - app is running 4 hours 9 minutes and still nothing here!
edit n1:
Only thing which is running on background is Timer executed each 17ms. I'm displaying hours, minutes, seconds and milis on screen thanks to it.
timer.scheduleAtFixedRate(new TimerTask() ...
currentTime = System.currentTimeMillis() - start;
milisecond = currentTime % 1000;
long x = currentTime / 1000;
second = x % 60;
x /= 60;
minute = x % 60;
x /= 60;
hour = x % 24;
variable start is another System.currentTimeMillis(). It has still value, assigned when this Timer was created.
It's also possible that S3 Mini was a bit "overworked", because I've been developing and testing on it from computer all the day (and the newest Android Studio eats quite a lot memory in phone against AS v1.0.0). I'll try another tests tomorow and let you know how it ended.

StartActivity suddenly stops starting another activity

The startActivity that was going fine without any problem suddenly got crashed and I get a message 'unfortunately apps has stopped working'. I put a breakpoint
and checked things, all goes well until it reaches the startActivity line.
The startActivity is not going to 'listviewtitles.class' at all. I also put a breakpoint at the beginning of this 'listviewtitles.class' but the debugger does not enter this class. In the startActivity if I change the 'listviewtitles.class' to another xyz.class it works well. At the same time, from 'another class' the startActivity goes to 'listviewtitles.class'. It seems the problem lies only between these two activities. Earlier it was going fine without any problem.
startActivity(new Intent( titles_new.this,listviewtitles.class));
In log cat it is like:
04-27 20:22:22.338 15020-15020/com.example.rajendran.myapplication W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
04-27 20:22:22.338 15020-15020/com.example.rajendran.myapplication W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
04-27 20:22:22.338 15020-15020/com.example.rajendran.myapplication W/dalvikvm﹕ threadid=1: calling UncaughtExceptionHandler
04-27 20:22:22.342 15020-15020/com.example.rajendran.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.rajendran.myapplication, PID: 15020
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at android.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:150)
at android.widget.CursorAdapter.getView(CursorAdapter.java:254)
at android.widget.AbsListView.obtainView(AbsListView.java:2338)
at android.widget.ListView.makeAndAddView(ListView.java:1813)
at android.widget.ListView.fillDown(ListView.java:698)
at android.widget.ListView.fillFromTop(ListView.java:759)
at android.widget.ListView.layoutChildren(ListView.java:1646)
at android.widget.AbsListView.onLayout(AbsListView.java:2149)
at android.view.View.layout(View.java:15140)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1160)
at android.view.View.layout(View.java:15140)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
at android.view.View.layout(View.java:15140)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
at android.view.View.layout(View.java:15140)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
at android.view.View.layout(View.java:15140)
at android.view.ViewGroup.layout(ViewGroup.java:4867)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2480)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2175)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6420)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
looks like your SimpleCursorAdapter is trying to access and array, and the index does not exits;
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1

Android Array Out of Bound Exception

I have built a Android App thats has a WebView to show a mobile website within the app.
I have started to get this exception on one device particularly
This issue is not seen on other devices.
I went through the source code and it looks like an issue with Android. Can any one help me understand that if we can do anything else in the app to suppress this exception
Note: In the stack trace, there is nothing related to the app code
AndroidAppCrashDump {"brand":"samsung","model":"GT-S6312","sdk":16,"android":"4.1.2","appVersion":"1.1.15","manufacturer":"samsung"}----java.lang.ArrayIndexOutOfBoundsException: length=1; index=1109619192 at
java.util.Arrays.fill(Arrays.java:855) at
android.support.v4.widget.ViewDragHelper.clearMotionHistory(ViewDragHelper.java:773) at
android.support.v4.widget.ViewDragHelper.cancel(ViewDragHelper.java:499) at
android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1031) at
android.support.v4.widget.DrawerLayout.onInterceptTouchEvent(DrawerLayout.java:868) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1877) at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) at
an droid.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2237) at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1979) at
com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2177) at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1482) at
android.app.Activity.dispatchTouchEvent(Activity.java:2469) at
android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.java:260) at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2125) at
android.view.View.dispatchPointerEvent(View.java:7414) at
android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3523) at
android.vi ew.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3455) at
android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4565) at
android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4543) at
android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4647) at
android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171) at
android.os.MessageQueue.nativePollOnce(Native Method) at
android.os.MessageQueue.next(MessageQueue.java:125) at
android.os.Looper.loop(Looper.java:124) at
android.app.ActivityThread.main(ActivityThread.java:4963) 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:1038) at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) at
dalvik.system.NativeStart.main(Native Method)

Service not registered: org.OpenUDID.OpenUDID_manager#2b038438

I have an application published in Google play and some time ago i received two error reports in my developer console which looks just like this:
java.lang.IllegalArgumentException: Service not registered: org.OpenUDID.OpenUDID_manager#2b038438
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:891)
at android.app.ContextImpl.unbindService(ContextImpl.java:921)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:352)
at org.OpenUDID.OpenUDID_manager.onServiceConnected(OpenUDID_manager.java:68)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1064)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1081)
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:3701)
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:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
at dalvik.system.NativeStart.main(Native Method)
and second:
java.lang.IllegalArgumentException: Service not registered: org.OpenUDID.OpenUDID_manager#40590d88
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:934)
at android.app.ContextImpl.unbindService(ContextImpl.java:952)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:352)
at org.OpenUDID.OpenUDID_manager.onServiceConnected(OpenUDID_manager.java:68)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1107)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1124)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4293)
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:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Can somebody explain me what is all this about? Non of the specified packages in stack trace are from my app.
Some of the libraries which i use are adcolony and appbooster. (I suppose that this libs might be the cause of problem).
Have a great new year 2014.if the answer is feasible than raise the answer and points :)
Hi i think i got the this problem please have a look.
Make sur you are using correct context.
one of these days
mService.unbindService(mConnection);
is obviously nonsense, calling unbind in the wrong context. It should be
unbindService(mConnection);
Additional mistake in the posted coding is the missing of
#Override
public boolean onUnbind(Intent intent) {
// All clients have unbound with unbindService()
return false;
}

android newbie question null pointer on ArrayAdapter.setAdapter

I have been slowing learning and building my first android app. I'm VERY new to java but have already done a couple of projects in C#, VB.NET (back in the day), Objective-C (have 6 apps in the store) and Fortran (waaaaaaaaaaaaaaaaaaaay back in the day ;)
So I just received from overseas a htc legend (I'm not in the US), which i bought in order to have a decent mid-level device for development (it's running non-rooted adnroid 2.1)
The application I have been developing is target level 4 (android 1.6). It uses a 5 Mb sqlite3 database with a .mp3 extension to avoid compression within the apk and proper copying from assets to system folder.
It all works fine on the emulator, and on the device I see that the file size of the app after copying the database matches exactly what I see on the emulator.
now, on my main activity with a list view and a spinner, I bind some data through two array adapters. when running on the device all does smoothly. but when trying to run on the device this part of the code:
public class mainAct extends Activity implements OnItemSelectedListener, TextWatcher, OnItemClickListener
{
/** members */
//private EditText searchtext;
private ListView designations;
private ArrayAdapter<String> adapterShapes;
private ArrayAdapter<String> adapterTypes;
private Spinner types;
.
.
.
public void onCreate(Bundle savedInstanceState)
{
.
.
.
// DESIGNATIONS
//
adapterShapes = new ArrayAdapter<String>(this,R.layout.list_item,shapes); // custom TextView Adapter
designations=(ListView)findViewById(R.id.designations);
Log.e("MAIN.ACCT", "ok to 172");
designations.setAdapter(adapterShapes);
Log.e("MAIN.ACCT", "ok to 174");
designations.setOnItemClickListener(this);
// TYPES
//
adapterTypes=new ArrayAdapter<String>(this,R.layout.spinner_item,DT.get().typesInLibrary);
types=(Spinner)findViewById(R.id.types);
types.setAdapter(adapterTypes);
types.setOnItemSelectedListener(this);
.
.
.
}
}
Both designations.setAdapter(adapterShapes);
& types.setAdapter(adapterTypes);
give me a Null Pointer exception.
I'm using eclipse under mac, the LogCat window throws:
06-25 18:41:37.842:
ERROR/AndroidRuntime(9523): Uncaught
handler: thread main exiting due to
uncaught exception
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523):
java.lang.RuntimeException: Unable to
start activity
ComponentInfo{com.davidhomes.steel/com.davidhomes.steel.mainAct}:
java.lang.NullPointerException
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.app.ActivityThread.access$2200(ActivityThread.java:126)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.os.Handler.dispatchMessage(Handler.java:99)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.os.Looper.loop(Looper.java:123)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.app.ActivityThread.main(ActivityThread.java:4595)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
java.lang.reflect.Method.invokeNative(Native
Method)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
java.lang.reflect.Method.invoke(Method.java:521)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
dalvik.system.NativeStart.main(Native
Method)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): Caused by:
java.lang.NullPointerException
-------------------------------------------------------------- 06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
com.davidhomes.steel.mainAct.onCreate(mainAct.java:183)
--------------------------------------------------------------
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
06-25 18:41:37.891:
ERROR/AndroidRuntime(9523): ... 11
more
06-25 18:46:38.252:
ERROR/ActivityManager(99): fail to set
top app changed!
Line 183 is the first setAdapter call (designations.setAdapter(adapterShapes);), when I comment it out the second setAdapter is the one breaking code
I'm a little lost here, the adapters show the proper number of items on the log window when running from the simulator and the device.
I admit to being a noob to both java and android, so any help is highly appreciated.
regards
david
Well, as you've probably figured out yourself, some variable is null. Unfortunately, there is no obvious source of the NullPointerException in your code.
Therefore, you should first try to identify what variable is null, and hence causing the exception.
For example, findViewById returns null if it cannot find the view, so you may want to double check your ListView and Spinner are being initialised properly.
Of course, the problem may be with your ArrayAdapters, so you should also check them, but from your question it sounds as if you've already done that.
Once you (and we) know exactly where the NullPointerException is occurring, it will be easier to give more specific advice
Oops! it was my fault all along, somehow I had TWO layouts (one for different resolutions), the one being used on my device did not have the proper ListView and Spinner ID. That alternative layout was collapse into a folder and I just forgot about it (I had paused development of the app for about 2 month until I actually got a device to test on).
the one working fine was installing on the simulator but not on the device and vice-versa, weird as the good one matches the resolution of my device (I'm pretty sure I'm also missing something there but that's not important right now)
Still, thanks Chris for pointing me to looking at the Null return value on findViewById. Being new to android I was lost as to were to begin
Best regards
david
I know this is a long closed subject. However I just came across the same problem and this post did not answer it.
What i did, was very silly. I forgot to add a reference to the xml. ie. setContentView(R.layout.settings);
it actually looks like the original post might have also forgotten this so i thought I would just post it.
Cheers.
I had the same problem. I put Log.d messages in printing out every object. It turned out that my ListView object was "null". The reason for this was I had the wrong XML activity listed in my SetContentView. I think the easiest way to debug this problem is keep putting in Log.d messages until you find the object/variable that is "null".

Categories

Resources