Android Question Crash Report - java.lang.NullPointerException (main._process_globals)

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I got a crash report in my Google Play Developer console and it says the following and I think it's all related to my Process_Globals sub..

java.lang.NullPointerException
in my.app.here.main._process_globals


B4X:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at my.app.here.activity1.initializeProcessGlobals(activity1.java:406)
    at my.app.here.activity1.afterFirstLayout(activity1.java:94)
    at my.app.here.activity1.access$100(activity1.java:16)
    at my.app.here.activity1$WaitForLayout.run(activity1.java:76)
    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:4950)
    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:1004)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at my.app.here.activity1.initializeProcessGlobals(activity1.java:404)
    ... 12 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
    at my.app.here.main.initializeProcessGlobals(main.java:689)
    ... 15 more
Caused by: java.lang.NullPointerException
    at my.app.here.main._process_globals(main.java:1242)
    at my.app.here.main.initializeProcessGlobals(main.java:661)
    ... 15 more

Page 2 of the same report it says:

B4X:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at my.app.here.activity2.initializeProcessGlobals(activity2.java:329)
    at my.app.here.activity2.afterFirstLayout(activity2.java:94)
    at my.app.here.activity2.access$100(activity2.java:16)
    at my.app.here.activity2$WaitForLayout.run(activity2.java:76)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5414)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at my.app.here.activity2.initializeProcessGlobals(activity2.java:327)
    ... 12 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
    at my.app.here.main.initializeProcessGlobals(main.java:689)
    ... 15 more
Caused by: java.lang.NullPointerException
    at my.app.here.main._process_globals(main.java:1242)
    at my.app.here.main.initializeProcessGlobals(main.java:661)
    ... 15 more


In my Process_Globals and Globals sub from the Main Activity it looks like this:
B4X:
Sub Process_Globals
 
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim SQL1 As SQL
   
    Dim sync_done, IP, PORT As String
    Dim intCount As Int
    Dim num_of_connections As Int = intCount
   
    Dim MainTimer As Timer
   
    Dim publicKey As String
   
        publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCA.............."
    Dim test1 As String
   
    Public DeviceBoardPassword, BoardUrl, SenderId, DeviceName As String
        DeviceBoardPassword = "test"
End Sub
 
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
 
    Dim add_tap As Label  
    Dim add_tap1 As Label 
    Dim Fade_splash As SplashFade  ' Used for splash screen
 
    Dim scvTest As ScrollView          'used on showing layout in scrollView
    Dim add_panel As Panel              'used on showing layout in scrollView
   
    Dim menu_scroll As HorizontalScrollView    'used to add bottom menu
    Dim menu_back_img As ImageView                'used to add bottom menu (background image)
   
    Dim scvMain1 As ScrollView
   
    Dim scvMain As ScrollView
    Dim PanelNb As Int            : PanelNb = 32
    Dim PanelNb1 As Int            : PanelNb1 = 32
    Dim PanelHeight As Int        : PanelHeight = 56dip
    Dim PanelHeight1 As Int        : PanelHeight1 = 60dip
    Dim next_location As Int    : next_location = 60dip
    Dim num_of_items As Int    : num_of_items = 0
    Dim zone_list As Panel
 
    Dim Days(7) As String
   
    Dim ac1 As AHQuickAction    ' used to show popup
    Dim item As String            ' used to show popup
   
    Dim img_button As ImageView
    Dim lbl2 As Label
   
    ' ---------------------------------------------------------------------------------------------
    ' used for menu button
    Dim main_settings_button As ImageView
    Dim men As AHPopupMenu
    '----------------------------------------------------------------------------------------------
   
    Dim SQL1 As SQL ' Used for getting data from database
   
   
    Dim version_num As Label
   
End Sub

In my Process_Globals and Globals sub from the Activity1 Activity it looks like this:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
    Dim SQL1 As SQL ' Used for getting data from database
   
   
    Dim sql_panel_number As String = 1    
    Dim IP As String                   
    Dim PORT As String
 
    Dim runTimer As Timer                ' used for dialog  
   
    Dim panel_state As String    
   
    Dim clearSync As Timer
   
    Dim connectiontimer As Timer
End Sub
 
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Dim scvTest As ScrollView                    'used on showing layout in scrollView
    Dim Panel1 As Panel                            'used on showing layout in scrollView
    Dim menu_scroll As HorizontalScrollView    'used to add bottom menu   
   
    Dim Panel1 As Panel
   
    Dim panel_armed_ball As ImageView
    Dim panel_ready_ball As ImageView
    Dim Button1 As Button
    Dim Button2 As Button
    Dim Button3 As Button
    Dim Button4 As Button
    Dim Button5 As Button
    Dim Button6 As Button
    Dim Button7 As Button
    Dim Button8 As Button
    Dim Button9 As Button
    Dim Button10 As Button
    Dim Button11 As Button
    Dim Button12 As Button
 
    Dim current_panel_status As String
    Dim pin As String 
 
    Dim keypad_icon As ImageView
   
    Dim label2 As Label   
    Dim label3 As Label   
 
    Dim input_icon As ImageView
    Dim output_icon As ImageView
 
    Dim AB, AB2 As ClsActionBar
    Dim HSV As HorizontalScrollView
    Dim pnlAB As Panel
    Dim pnlMain As Panel
    Dim RadioButton1 As RadioButton
    Dim RadioButton2 As RadioButton
    Dim RadioButton3 As RadioButton
    Dim RadioButton4 As RadioButton
    Dim ToggleDividers As ToggleButton
    Dim ToggleEquallySized As ToggleButton
    Dim ToggleCustomBackground As ToggleButton
    Dim AddButton As Button
    Dim LastTab As View
    Dim BtnHome As View
   
    Dim menu_function_side_button As ImageView
    Dim menu_quick_arm_side_button As ImageView
   
    Dim show_quick_arm_menu_timer As Timer
        show_quick_arm_menu_timer.Initialize ("show_quick_arm_menu_timer",1)
        show_quick_arm_menu_timer.Enabled = False
       
    Dim hide_quick_arm_menu_timer As Timer
        hide_quick_arm_menu_timer.Initialize ("hide_quick_arm_menu_timer",1)
        hide_quick_arm_menu_timer.Enabled = False
       
    Dim hide_quick_function_menu_timer As Timer
        hide_quick_function_menu_timer.Initialize ("hide_quick_function_menu_timer",1)
        hide_quick_function_menu_timer.Enabled = False   
 
    Dim connecting_panel As Panel
    Dim title_1 As Label
    Dim title_2 As Label
    Dim connecting_top_title As Label
    Dim connection_err_button As Button
   
    Dim kpareatimer As Timer
        kpareatimer.Initialize("kpareatimer",2000)
        kpareatimer.Enabled = True
        kpareatimer.Interval = 2000
    Dim hide_quick_arm As Label   
       
    Dim hide_quick_function As Label
    Dim quck_function_panel As Panel
   
    Dim fkey_flashing As Timer
        fkey_flashing.Initialize("fkey_flashing",1000)
        fkey_flashing.Enabled = True
        fkey_flashing.Interval = 1000
   
    Dim current_flashing_F1,current_flashing_F2,current_flashing_F3,current_flashing_F4,current_flashing_F5,current_flashing_F6 As String = "0"
    Dim connecting_panel_error As Panel
        connecting_panel_error.Initialize (connecting_panel_error)
    Dim title_1_a As Label
        title_1_a.Initialize(title_1_a)
    Dim panel_time_date_label As Label
   
    Dim checkTime_and_status As Timer    ' used to check if time/date & panel status is shown as a backup
 
    Dim main_settings_button As ImageView
    Dim men As AHPopupMenu
    Dim main_title As Label
    Dim label1 As Label 'connected / not connected label
End Sub






In my Process_Globals and Globals sub from the Activity2 Activity it looks like this:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim datab As local_storage1
   
    Dim Timer1 As Timer
End Sub
 
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Dim scvTest As ScrollView          'used on showing layout in scrollView
    Dim add_panel As Panel              'used on showing layout in scrollView
   
    Dim ULV As ClsUltimateListView
    Dim ItemHeight As Int = 50dip
    Dim CancelList As List
    Dim Cancel1List As List
   
    Dim menu_scroll As HorizontalScrollView
   
    Dim ac1 As AHQuickAction 
    Dim item As String 
 
    Dim AB, AB2 As ClsActionBar
    Dim HSV As HorizontalScrollView
    Dim pnlAB As Panel
    Dim pnlMain As Panel
    Dim RadioButton1 As RadioButton
    Dim RadioButton2 As RadioButton
    Dim RadioButton3 As RadioButton
    Dim RadioButton4 As RadioButton
    Dim ToggleDividers As ToggleButton
    Dim ToggleEquallySized As ToggleButton
    Dim ToggleCustomBackground As ToggleButton
    Dim AddButton As Button
    Dim LastTab As View
    Dim BtnHome As View
 
    Dim main_settings_button As ImageView
    Dim men As AHPopupMenu
 
    Dim main_title As Label
    Dim loaded As String = "0"
End Sub

In my Activity1 Globals I have for some reason added 'Dim Panel1 As Panel' there twice.
Could this be the thing stuffing up my app ?

I also thought I wasn't using 'Initialize' in the Globals and thought I was doing that in the Activity_Create sub but looks like I am not, so could this also stuff up the app and the reason why its creating this crash report.

The thing I like to know as well, why does my app work fine on my 4 Android devices, but on some other devices this crash happens ? (maybe android devices are all different in a way?)

Anyone know why my app happens to crash based on the above?
(I don't want to upload my project to the forum)
 

aaronk

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Its complied in 'Release (obfuscated)'.

Here is the code from main.java that you wanted to see..
(I opened the file in Notepad++ and took a screenshot for you)

Let me know if you need anything else.

 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
This is the code from main.java

The Java code I am posting (from the other post and this post) is the latest code and would of been the code that has been submitted to Google Play.
I have done some changes but the code posted has not been affected as I have copyied this Java code from a backup before I made the changes which hasn't been uploaded to Google Play yet.

There are some parts below I have edited with the word 'REMOVED' below that I have removed as I don't think the PublicKey or my domain name is required here.. (just in case we have some sticky beaks )

B4X:
public static String  _process_globals() throws Exception{
//BA.debugLineNum = 12;BA.debugLine="Sub Process_Globals";
//BA.debugLineNum = 15;BA.debugLine="Dim SQL1 As SQL";
mostCurrent._vvvvv1 = new anywheresoftware.b4a.sql.SQL();
//BA.debugLineNum = 17;BA.debugLine="Dim sync_done, IP, PORT As String";
_sync_done = "";
_vvvvv3 = "";
_vvvvv4 = "";
//BA.debugLineNum = 18;BA.debugLine="Dim intCount As Int";
_vvvvvvv0 = 0;
//BA.debugLineNum = 19;BA.debugLine="Dim num_of_connections As Int = intCount";
_num_of_connections = _vvvvvvv0;
//BA.debugLineNum = 21;BA.debugLine="Dim MainTimer As Timer";
_vvvvvvvv5 = new anywheresoftware.b4a.objects.Timer();
//BA.debugLineNum = 23;BA.debugLine="Dim publicKey As String";
_vvvvvvvv6 = "";
//BA.debugLineNum = 25;BA.debugLine="publicKey = \"REMOVED\"";
_vvvvvvvv6 = BA.__b (new byte[] {22,81,-59,-9,20,41,-98,-7,69,37,-70,-33,50,115,-32,-19,127,53,-17,-16,89,8,-107,-24,30,70,-35,-24,7,22,-8,-24,84,16,-100,-13,7,97,-39,-19,24,13,-124,-24,119,36,-6,-44,34,59,-5,-31,28,101,-106,-2,65,44,-65,-25,35,92,-27,-29,8,49,-107,-1,108,3,-106,-102,31,46,-27,-56,21,46,-88,-59,55,0,-96,-55,43,96,-37,-47,21,33,-93,-1,109,114,-30,-122,61,41,-7,-37,3,36,-78,-111,36,7,-106,-60,19,121,-30,-61,57,21,-78,-9,94,63,-108,-10,24,96,-50,-29,42,42,-101,-45,127,13,-98,-25,63,42,-26,-40,18,24,-79,-126,76,31,-66,-41,29,93,-56,-32,35,119,-116,-5,94,26,-69,-33,60,54,-62,-12,12,56,-88,-54,79,39,-93,-126,1,44,-36,-15,109,4,-98,-46,66,54,-9,-15,34,42,-50,-32,8,42,-69,-25,118,59,-100,-35,32,45,-6,-51,10,22,-111,-53,83,51,-65,-3,23,77,-11,-56,114,42,-73,-26,119,44,-80,-124,116,118,-42,-53,9,52,-74,-97,70,20,-5,-42,12,70,-17,-12,119,41,-3,-32,54,3,-113,-57,29,65,-71,-51,110,47,-77,-121,76,51,-87,-123,61,113,-60,-13,55,14,-122,-13,43,8,-86,-99,104,113,-40,-58,45,3,-82,-29,125,56,-122,-121,117,119,-92,-3,44,12,-120,-18,122,109,-2,-36,112,80,-36,-25,53,26,-76,-7,82,32,-83,-124,56,51,-29,-126,11,47,-106,-4,115,1,-26,-56,44,97,-19,-48,113,1,-108,-22,109,109,-101,-24,58,109,-5,-52,12,114,-11,-39,117,107,-115,-11,45,82,-2,-59,11,56,-124,-18,118,127,-83,-56,54,72,-20,-7,61,45,-112,-29,53,49,-121,-123,62,72,-59,-41,49,49,-116,-122,95,52,-67,-35,107,95,-70,-97,3,105,-73,-34,65,108,-90,-17,44,86,-37,-17,7,22,-127,-21}, 259998);
//BA.debugLineNum = 26;BA.debugLine="Dim test1 As String";
_vvvvvvvv7 = "";
//BA.debugLineNum = 28;BA.debugLine="Public DeviceBoardPassword, BoardUrl, SenderId, DeviceName As String";
_vvvvvvvv0 = "";
_vvvvvvvvv1 = "";
_vvvvvvvvv2 = "";
_vvvvvvvvv3 = "";
//BA.debugLineNum = 29;BA.debugLine="DeviceBoardPassword = \"34f34fkj02d3\"";
_vvvvvvvv0 = BA.__b (new byte[] {104,45,-59,84,105,36,-101,15,55,113,-102,79}, 783836);
//BA.debugLineNum = 33;BA.debugLine="SenderId = \"980855498908\"";
_vvvvvvvvv2 = BA.__b (new byte[] {98,32,-8,30,104,118,-81,29,63,123,-91,5}, 366755);
//BA.debugLineNum = 34;BA.debugLine="BoardUrl = \"http://www.REMOVED.net/push\"";
_vvvvvvvvv1 = BA.__b (new byte[] {51,109,111,61,103,109,103,56,112,52,104,50,40,118,119,54,53,44,46,62,54,54,34,34,112,118,112,32,46}, 453816);
//BA.debugLineNum = 35;BA.debugLine="End Sub";
return "";
}
public static String  _vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv3() throws Exception{
int _i = 0;
//BA.debugLineNum = 641;BA.debugLine="Sub removeallpages";
//BA.debugLineNum = 643;BA.debugLine="Dim i As Int";
_i = 0;
//BA.debugLineNum = 644;BA.debugLine="For i = Activity.NumberOfViews - 1 To 0 Step -1";
{
final int step369 = (int) (-1);
final int limit369 = (int) (0);
for (_i = (int) (mostCurrent._activity.getNumberOfViews()-1); (step369 > 0 && _i <= limit369) || (step369 < 0 && _i >= limit369); _i = ((int)(0 + _i + step369))) {
//BA.debugLineNum = 645;BA.debugLine="Activity.RemoveViewAt(i)";
mostCurrent._activity.RemoveViewAt(_i);
}
};
//BA.debugLineNum = 647;BA.debugLine="End Sub";
return "";
}
public static String  _vvvv0(String _inanimation,String _outanimation) throws Exception{
anywheresoftware.b4a.agraham.reflection.Reflection _r = null;
String _package = "";
int _in = 0;
int _out = 0;
//BA.debugLineNum = 650;BA.debugLine="Sub SetAnimation(InAnimation As String, OutAnimation As String)";
//BA.debugLineNum = 651;BA.debugLine="Dim r As Reflector";
_r = new anywheresoftware.b4a.agraham.reflection.Reflection();
//BA.debugLineNum = 652;BA.debugLine="Dim package As String";
_package = "";
//BA.debugLineNum = 653;BA.debugLine="Dim In, out As Int";
_in = 0;
_out = 0;
//BA.debugLineNum = 654;BA.debugLine="package = r.GetStaticField(\"anywheresoftware.b4a.BA\", \"packageName\")";
_package = BA.ObjectToString(_r.GetStaticField("anywheresoftware.b4a.BA","packageName"));
//BA.debugLineNum = 655;BA.debugLine="In = r.GetStaticField(package & \".R$anim\", InAnimation)";
_in = (int)(BA.ObjectToNumber(_r.GetStaticField(_package+".R$anim",_inanimation)));
//BA.debugLineNum = 656;BA.debugLine="out = r.GetStaticField(package & \".R$anim\", OutAnimation)";
_out = (int)(BA.ObjectToNumber(_r.GetStaticField(_package+".R$anim",_outanimation)));
//BA.debugLineNum = 657;BA.debugLine="r.Target = r.GetActivity";
_r.Target = (Object)(_r.GetActivity(processBA));
//BA.debugLineNum = 658;BA.debugLine="r.RunMethod4(\"overridePendingTransition\", Array As Object(In, out), Array As String(\"java.lang.int\", \"java.lang.int\"))";
_r.RunMethod4("overridePendingTransition",new Object[]{(Object)(_in),(Object)(_out)},new String[]{"java.lang.int","java.lang.int"});
//BA.debugLineNum = 659;BA.debugLine="End Sub";
return "";
}
}
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
I will just re-submit the new update and See if the same error happens again or not.

Thanks heaps for your help.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…