Android Question An error has occurred in sub: 'void android.widget.LinearLayout.SetOrientation(int)'

TheWind777

Active Member
Licensed User
Longtime User
I'm getting a strange error when the App has been dormant for many hours, then restarted.

An error has occurred in sub:
java.lang.NullPointerException Attempt to invoke virtual method 'void android.widget.LinearLayout.setOrientation(int)' on a null object reference Continue?

If you click Yes to continue, it starts the App just fine.

LogCat connected to: 0781162c
--------- beginning of crash
--------- beginning of system
--------- beginning of main
GIFDECODER DEFINED
** Activity (main) Create, isFirst = false **
LocationManager has been initialized.
** Activity (main) Resume **
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.setOrientation(int)' on a null object reference
at anywheresoftware.giuseppe.salvi.toast.ToastMessageShowWrapper.showView(ToastMessageShowWrapper.java:760)
at anywheresoftware.giuseppe.salvi.toast.ToastMessageShowWrapper.Show4(ToastMessageShowWrapper.java:442)
at b4a.acimwow.main._show_toast(main.java:26507)
at b4a.acimwow.main._toast(main.java:28919)
at b4a.acimwow.main._next_item_is_smaller(main.java:18569)
at b4a.acimwow.main._adjust_upcoming_event_if_necessary(main.java:3287)
at b4a.acimwow.main._check_upcoming_event(main.java:6948)
at b4a.acimwow.main._timer_queue_tick(main.java:28369)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:200)
at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:168)
at anywheresoftware.b4a.keywords.Common.DoEvents(Common.java:380)
at b4a.acimwow.overlord._do_events(overlord.java:625)
at b4a.acimwow.overlord._overlord_timer_queue_tick(overlord.java:2120)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:200)
at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:168)
at anywheresoftware.b4a.keywords.Common.DoEvents(Common.java:380)
at b4a.acimwow.main._do_events(main.java:10389)
at b4a.acimwow.main._prepare_duration_sound(main.java:19017)
at b4a.acimwow.main._activity_resume(main.java:2409)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at b4a.acimwow.main.afterFirstLayout(main.java:104)
at b4a.acimwow.main.access$100(main.java:16)
at b4a.acimwow.main$WaitForLayout.run(main.java:76)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.setOrientation(int)' on a null object reference
** Activity (main) Pause, UserClosed = true **
No partial wakelock.
GIFDECODER DEFINED
** Activity (main) Create, isFirst = false **
LocationManager has been initialized.
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
GIFDECODER DEFINED
** Activity (main) Create, isFirst = false **
LocationManager has been initialized.
** Activity (main) Resume **

The internet says the function is: "A Layout that arranges its children in a single column or a single row. The direction of the row can be set by calling setOrientation()."


I assume it is occurring when the Layouts are being formed, and a android.widget.LinearLayout.SetOrientation(LinearLayout.HORIZONTAL) or android.widget.LinearLayout.SetOrientation(LinearLayout.VERTICAL) are being performed.

Any ideas what might be causing the problem? Is Android killing either the Service Module or the Main Thread, and then it tries to start with a null reference, or something? If so, how can I ensure this error doesn't occur?

The App, itself, is working perfectly. I made no revisions on any Layout file, recently, that I can think of.

This error started popping-up only yesterday.

I'm sure I could do a Try/Catch on it, if I knew what was happening.

When I go to the Google Play Store to see if anybody is having crashes, it says "Crashes and ANRs - 0"; but that doesn't say they aren't getting the same requester and clicking 'YES' to continue. So, I don't know if the error is just on my Nexus 7 2nd Version.

I am running the new LOLLIPOP 5.0.0 Newest Preview (API 21)

( I suspect it is occurring in the Activity_Resume routine. I am putting Debug Log() scattered through it to tell just where it might be happening.)
 
Last edited:

TheWind777

Active Member
Licensed User
Longtime User
What is anywheresoftware.giuseppe.salvi.toast.ToastMessageShowWrapper ?

I found it.

It was occurring in a Toast Library (ToastMessageShow v1.70). I just reverted to using the regular Toast instead of a colored toast using that Library in that place in the App and the problem went away.

Thanks for looking...
 
Upvote 0
Top