Android Question java.lang.Exception / anywheresoftware.b4a.BA.raiseEvent2 (BA.java:227)

Marco Nissen

Active Member
Licensed User
Longtime User
Hi

on a few devices, I get this issue. I don't know what's wrong because for the majority of devices, the exception does not occur.
I am currently using B4A 12.50 and target is set to API 33 and device (pixel5 is also at 33)

Thanks
Marco

B4X:
Exception java.lang.Exception:
  at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:227)
  at anywheresoftware.b4a.keywords.Common$12$1.run (Common.java:1197)
  at anywheresoftware.b4a.BA.setActivityPaused (BA.java:467)
  at com.wurzelkraut.Stash2Go.main.afterFirstLayout (main.java:109)
  at com.wurzelkraut.Stash2Go.main.access$000 (main.java:17)
  at com.wurzelkraut.Stash2Go.main$WaitForLayout.run (main.java:83)
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8762)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)

B4X:
private void afterFirstLayout() {
        if (this != mostCurrent)
            return;
        activityBA = new BA(this, layout, processBA, "com.wurzelkraut.Stash2Go", "com.wurzelkraut.Stash2Go.main");
        
        processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
        anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
        _activity = new ActivityWrapper(activityBA, "activity");
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (BA.isShellModeRuntimeCheck(processBA)) {
            if (isFirst)
                processBA.raiseEvent2(null, true, "SHELL", false);
            processBA.raiseEvent2(null, true, "CREATE", true, "com.wurzelkraut.Stash2Go.main", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
            _activity.reinitializeForShell(activityBA, "activity");
        }
        initializeProcessGlobals();       
        initializeGlobals();
        
        BA.LogInfo("** Activity (main) Create " + (isFirst ? "(first time)" : "") + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
        isFirst = false;
        if (this != mostCurrent)
            return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (main) Resume **");
        processBA.raiseEvent(null, "activity_resume");
        if (android.os.Build.VERSION.SDK_INT >= 11) {
            try {
                android.app.Activity.class.getMethod("invalidateOptionsMenu").invoke(this,(Object[]) null);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
 
Last edited:

Marco Nissen

Active Member
Licensed User
Longtime User
Note that this Java code is generated by the B4A framework. I have extended the code to the maximum of the function.
I don't have more debug information available.

I was hoping if Erel could have a look at BA.java in the specific line, or if somebody else had a similar issue. Again, I cannot reproduce it on any of my devices, and in the specific line of the B4A code, nothing has been called yet except that the activity_create event is being raised and activity_resume is obviously not yet called but it is trying to pause the activity.

B4X:
Sub Activity_Create(FirstTime As Boolean)

And: only 10 people out of 10.000 have this issue, but I would like to get rid of this issue if somehow possible.
 
Last edited:
Upvote 0

Marco Nissen

Active Member
Licensed User
Longtime User
Just running the app. Of course i did not modify any Java code. As I said it is an issue related to the B4a framework most likely. You can look into the generated code from your apps - will look the same
 
Upvote 0

Marco Nissen

Active Member
Licensed User
Longtime User
There is nothing here to help us help you. Do you have a full stack trace giving the actual exception type?
Again, I only have that what I have. And it points clearly in the direction of the B4A framework, not the app code. So I appreciate that you want to support debugging, but I think unless you have access to the actual framework source code you won't know anyways what the root cause it.

Again, if anybody encountered this and could solve that please share.

So to be more explicit - something is happening in line 227 of the BA.java file (version 12.50) written I suppose maybe by @Erel that is causing the exception.
Therefore, any hint what that could be is greatly appreciated.

And no, I did not modify any generated code, or did anything fancy or complex here.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
And it points clearly in the direction of the B4A framework, not the app code.
sure the framework is involved. But if you look at the full stacktrace it will point out where it happens. in your code.

It would be of great help if you create a small project showing the issue and upload it.
Withoup knowing what exactly the b4a code is we can not help..

Start with posting the full stacktrace then we can invest further
 
Upvote 0

Marco Nissen

Active Member
Licensed User
Longtime User
Again, it occurs only in 10 of 10.000 devices, and I don't have access to those, or a full stack trace.
At least I have access to one of these users, and she is currently trying to figure out how to install a "debug" version.
However, the issue is that it crashes right in the beginning.

I don't think that you can investigate a lot, I was asking if somebody had already seen this, or if somebody could give a hint based on the BA.java reference.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Well they all seem to be either Google or Samsung products - overwhelmingly Samsung - so there seems to be a correlation there. However none of those model names seem to exist as far as GSMArena is concerned. Do you have a list of the Android versions they are running?
 
Upvote 0

Marco Nissen

Active Member
Licensed User
Longtime User
sure, but not sure if it helps
also i am trying now to use firebase/crashlytics and (again, I removed it due to data privacy concerns) produce some more information

Main:
Sub Globals
...
Public ah As AttributeHelper
...
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ah.Initialize(Activity)
    Log("LAUNCH: app launch started ")
...
End Sub

AttributeHelper:
Public Sub Initialize(newActivity As Activity)
    If newActivity <> Null And newActivity.IsInitialized Then
        Log(newActivity.Title & " created")
    Else
        Log("empty attribute helper created")
    End If
    myActivity = newActivity
    lblfontAwesome.Initialize("font")
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…