main_globals Error!

stefanoa

Active Member
Licensed User
Longtime User
suddenly get this error while loading the form activity, I can not figure out why it may depend:

An error has occurred in sub:main_globals (java line: 2358) java.lang.NullPointerException

this is the log:
main_globals (java line: 2358)

java.lang.NullPointerException
at b4a.example.main._globals(main.java:2358)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at b4a.example.main.initializeGlobals(main.java:226)
at b4a.example.main.afterFirstLayout(main.java:86)
at b4a.example.main.access$100(main.java:16)
at b4a.example.main$WaitForLayout.run(main.java:74)
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:3717)
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:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)


java.lang.NullPointerException

HELP! :sign0085:
 

agraham

Expert
Licensed User
Longtime User
With no other information and no code it is impossible to say. If you open the main.java file that you will find in a folder somewhere below Object/src with a line numbering editor like Notepad++ and look for line 2358 it will give you an idea of what the problem is. As it is in Globals it looks like an variable or object initialisation error of some kind.
 
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
thanks for the important suggestion..

the code block is this:
B4X:
   public void onPause() {
      super.onPause();
        if (_activity == null) //workaround for emulator bug (Issue 2423)
            return;
      anywheresoftware.b4a.Msgbox.dismiss(true);
        anywheresoftware.b4a.keywords.Common.Log("** Activity (game) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());      
        processBA.setActivityPaused(true);
        mostCurrent = null;
        if (!activityBA.activity.isFinishing())
         previousOne = new WeakReference<Activity>(this);
        anywheresoftware.b4a.Msgbox.isDismissing = false;
   }

the row is:
B4X:
        processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());
 
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
fixed!
the panel ExtraPanel was used prior to declaration..
it was difficult to find since the error was general and my "sub globals" is very large.. :)
thanks very much for your tips!!!!

B4X:
Sub Globals
......
Dim screenMarginLeft As Int = extraPanel.Left+extraPanel.width
.....
Dim extraPanel As Panel
...
End Sub

fixed with:
B4X:
Sub Globals
......
Dim extraPanel As Panel
Dim screenMarginLeft As Int 
...
End Sub

sub StartGame
....
screenMarginLeft = extraPanel.Left+extraPanel.width
...
end sub
 
Upvote 0
Top