Android Question weird problem after publishing to Google play

Devv

Active Member
Licensed User
Longtime User
the app was working perfectly with release/debug mode

after publishing to play the app is crashing on some devices

Today, 11:28 AM on app version 25

Huawei HUAWEI Y7 Prime 2018 (HWLDN-Q), Android 8.0
Report 1 of 3



java.lang.RuntimeException
:

at anywheresoftware.b4a.BA.parseBoolean (BA.java:612)

at anywheresoftware.b4a.BA.ObjectToBoolean (BA.java:682)

at com.beisat.android.starter._service_create (starter.java:205)

at java.lang.reflect.Method.invoke (Native Method)

at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:196)

at anywheresoftware.b4a.BA.raiseEvent (BA.java:176)

at com.beisat.android.starter.onCreate (starter.java:56)

at android.app.ActivityThread.handleCreateService (ActivityThread.java:3967)

at android.app.ActivityThread.-wrap5 (Unknown Source)

at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2092)

at android.os.Handler.dispatchMessage (Handler.java:108)

at android.os.Looper.loop (Looper.java:166)

at android.app.ActivityThread.main (ActivityThread.java:7529)

at java.lang.reflect.Method.invoke (Native Method)

at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)

at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)



i was never able to reproduce the crash on my device

i was able to put my hand on one devices the app is crashing on (galaxy s7 edge)
here is crash log



*** Service (starter) Create ***
starter_service_create (java line: 205)
java.lang.RuntimeException: Cannot parse: null as boolean
at anywheresoftware.b4a.BA.parseBoolean(BA.java:612)
at anywheresoftware.b4a.BA.ObjectToBoolean(BA.java:682)
at com.beisat.android.starter._service_create(starter.java:205)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at com.beisat.android.starter.onCreate(starter.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
at android.app.ActivityThread.-wrap4(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)


the weird thing is that installing the same app with b4a bridge it will work perfectly

while uploading the exact same apk to google play store will case a crash on these devices !!


starter service code

B4X:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim language As String
    Dim config, translation As Map
    Dim night_mode As Boolean
End Sub

Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    config.Initialize
    translation.Initialize
   
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
   
    'gets or sets the app language
    If File.Exists(File.DirInternal, "config.map") Then
        config = File.ReadMap(File.DirInternal, "config.map")
        language = config.Get("lang")
        night_mode = config.Get("night_mode")
    Else 'if config file not found
        If Get_Language.Contains("ar") Then
            language = "ar"
        Else
            language = "en"
        End If
        config.Put("lang", language)
       
        config.Put("night_mode", False)
        File.WriteMap(File.DirInternal, "config.map", config)
    End If
   
    translation = File.ReadMap(File.DirAssets, "translation.lang")
   
End Sub



Sub Service_Start (StartingIntent As Intent)
   

End Sub


Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy

End Sub




java code

B4X:
public static String  _service_create() throws Exception{
RDebugUtils.currentModule="starter";
if (Debug.shouldDelegate(processBA, "service_create", false))
     {return ((String) Debug.delegate(processBA, "service_create", null));}
RDebugUtils.currentLine=6029312;
//BA.debugLineNum = 6029312;BA.debugLine="Sub Service_Create";
RDebugUtils.currentLine=6029315;
//BA.debugLineNum = 6029315;BA.debugLine="config.Initialize";
_config.Initialize();
RDebugUtils.currentLine=6029316;
//BA.debugLineNum = 6029316;BA.debugLine="translation.Initialize";
_translation.Initialize();
RDebugUtils.currentLine=6029318;
//BA.debugLineNum = 6029318;BA.debugLine="CallSubDelayed(FirebaseMessaging, \"SubscribeToTop";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._firebasemessaging.getObject()),"SubscribeToTopics");
RDebugUtils.currentLine=6029321;
//BA.debugLineNum = 6029321;BA.debugLine="If File.Exists(File.DirInternal, \"config.map\") Th";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"config.map")) {
RDebugUtils.currentLine=6029322;
//BA.debugLineNum = 6029322;BA.debugLine="config = File.ReadMap(File.DirInternal, \"config.";
_config = anywheresoftware.b4a.keywords.Common.File.ReadMap(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"config.map");
RDebugUtils.currentLine=6029323;
//BA.debugLineNum = 6029323;BA.debugLine="language = config.Get(\"lang\")";
_language = BA.ObjectToString(_config.Get((Object)("lang")));
RDebugUtils.currentLine=6029324;
//BA.debugLineNum = 6029324;BA.debugLine="night_mode = config.Get(\"night_mode\")";
_night_mode = BA.ObjectToBoolean(_config.Get((Object)("night_mode")));
}else {
RDebugUtils.currentLine=6029326;
//BA.debugLineNum = 6029326;BA.debugLine="If Get_Language.Contains(\"ar\") Then";
if (_get_language().contains("ar")) {
RDebugUtils.currentLine=6029327;
//BA.debugLineNum = 6029327;BA.debugLine="language = \"ar\"";
_language = "ar";
}else {
RDebugUtils.currentLine=6029329;
//BA.debugLineNum = 6029329;BA.debugLine="language = \"en\"";
_language = "en";
};
RDebugUtils.currentLine=6029331;
//BA.debugLineNum = 6029331;BA.debugLine="config.Put(\"lang\", language)";
_config.Put((Object)("lang"),(Object)(_language));
RDebugUtils.currentLine=6029333;
//BA.debugLineNum = 6029333;BA.debugLine="config.Put(\"night_mode\", False)";
_config.Put((Object)("night_mode"),(Object)(anywheresoftware.b4a.keywords.Common.False));
RDebugUtils.currentLine=6029334;
//BA.debugLineNum = 6029334;BA.debugLine="File.WriteMap(File.DirInternal, \"config.map\", co";
anywheresoftware.b4a.keywords.Common.File.WriteMap(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"config.map",_config);
};
RDebugUtils.currentLine=6029337;
//BA.debugLineNum = 6029337;BA.debugLine="translation = File.ReadMap(File.DirAssets, \"trans";
_translation = anywheresoftware.b4a.keywords.Common.File.ReadMap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"translation.lang");
RDebugUtils.currentLine=6029339;
//BA.debugLineNum = 6029339;BA.debugLine="End Sub";
return "";
}


here is the app link to google play

any help is highly appreciated
 
Last edited:

Devv

Active Member
Licensed User
Longtime User
My guess is that the submitted code is not identical to that code. Maybe you changed something after release. I don't see where this error can happen in Service_Create.

What is line 205 in the java code?
B4X:
_night_mode = BA.ObjectToBoolean(_v6.Get((Object)("night_mode")));
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Now it is clear. I missed the boolean type.

Change your code to:
B4X:
 If File.Exists(File.DirInternal, "config.map") Then
        config = File.ReadMap(File.DirInternal, "config.map")
        language = config.GetDefault("lang", "en")
        night_mode = config.GetDefault("night_mode", False)
    Else

This way it will work after you add a new property.
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
Now it is clear. I missed the boolean type.

Change your code to:
B4X:
If File.Exists(File.DirInternal, "config.map") Then
        config = File.ReadMap(File.DirInternal, "config.map")
        language = config.GetDefault("lang", "en")
        night_mode = config.GetDefault("night_mode", False)
    Else

This way it will work after you add a new property.


thanks for replay

i still cant understand the following

1- why using config.Get() is wrong ?
2- why it was making the crash on some devices only ?
3- why the crash on these devices only happened when the app is installed from google play ?
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
the error happened on a clean install

this means that the app should never enter the if statement on the first run ! because the config file will never be there on the first run
 
Upvote 0
Top