Other B4A v13.5 - integrated code bundle and more

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm happy to release a new version of B4A. The integrated code bundle tool is now available in B4A (and B4J).
Code Bundle is a tool that packs your project together with additional relevant information into a single json file, that can be provided to AI assistants for debugging, learning, refactoring and other tasks.

B4A_kf7zblfSEr.gif


The bundle is created with a click of a button (Ctrl + R). The bundle includes:

  • Project code + list of public APIs. Keys are sanitized based on heuristic templates.
  • (optional) Logs + compilation output + warnings and errors list. Compilation output is included when the dialog is visible.
  • (optional) Layouts + designer script.
  • (optional) Paths configuration.
  • List of files. Files content is not added.
  • List of libraries with additional information for each library.
  • Manifest editor.
  • Current caret location with the code around it - the AI knows where you are focused on right now.
  • Additional information about the IDE and useful links for the AI to find more information.
How to use:
- Click on Ctrl + R. A json file will be created and copied to the clipboard. Paste into the AI assistant and ask questions.

Other improvements:
  • The Starter service is being deprecated due to restrictions applied by Android, which can lead to crashes in debug mode, and it becoming less useful with B4XPages. Removing the Starter service no longer affects the behavior of unhandled exceptions.
  • New warning in B4XPages projects when the starter service is included.
  • Application_Error sub can be added to the Main module (when the Starter service is excluded).
  • B4XPages project template updated accordingly.
  • #ExcludeCodeFromBundle attribute - set to True to exclude the current module from the code bundle. Note that public sub signatures and comments (before the subs only) will still be included in the bundle.
  • New log filter:

    View attachment 171493
    Error - includes the app logs and system level error logs. Very useful when looking for ANRs, startup errors and other mysterious crashes.
  • Autocomplete in #If lines.
  • List.Sublist - Very fast method that returns a read-only sub-list.
  • Fix for String.ToLower not explicitly setting the locale. Mainly fixes the Turkish I: https://www.b4x.com/android/forum/t...ctly-for-the-turkish-language.163961/#content
  • New #Macro / comment link options: (case insensitive)
    • librariesrefresh - set to True to automatically refresh the libraries after the task runs.
    • codesync - set to True to force the IDE to synchronize the code modules with the files.
    • autosave - set to True to automatically save the project BEFORE running the task. Note that Tools - IDE Options - Auto Save should be enabled for this to have effect.
    • filessync (not new) - set to True to synchronize the Files tab after the task.
    • cleanproject (not new) - set to True to "clean project" after the task
    • %STATE1% - new variable that causes the IDE to create a temporary file with the IDE state based on the new options under Tools - IDE Options. The file path will be passed to the process. This is used by Code Bundle and can be used by other similar tools. Note that the format can be modified in the future.
    • NoTimeout - set to True to disable the default process timeout (currently not available in B4J).
    • ide://KillProcesses - new option to kill all the currently running processes. Useful when running non-ui processes with no timeout (currently not available in B4J).

      Note that starting a B4J app as an external tool is as simple as:
      B4X:
      ide://run?File=<path to jar>\App.jar&NoTimeout=True
  • B4X Map collection can now wrap Java Maps.
  • Internal libraries updated.
  • Other bug fixes and minor improvements.
Download link: https://www.b4x.com/b4a.html
 

aeric

Expert
Licensed User
Longtime User
New #Macro / comment link options: (case insensitive)

This page needs update:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
ListOfArrays, a relatively new and most important library, is included as an internal library.
Tutorials and examples: https://www.b4x.com/android/forum/pages/results/?query=[loa]

And I will also push DBQuery which sits as a thin layer above the platform specific SQL libraries and provides a much improved API:
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
B4XPages project template updated accordingly.
Thanks Erel,

Are there any changes we need to make to the existing B4XPages apps we currently have running?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Are there any changes we need to make to the existing B4XPages apps we currently have running?
Assuming that you haven't added anything to the starter service then simply add this sub to the Main module:
B4X:
'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

And remove the starter service.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
My observation in previous versions, if we read the b4a project file (.b4a) using text editor, I noticed the version numbers.
B4X:
Version=13.4
B4X:
Version=13.45
but I just created a new B4XPages, I get:
B4X:
Version=9.9
Shouldn't it written as?
B4X:
Version=13.5

Then at the lower part, I see:
B4X:
'Template version: B4A-1.01
Maybe it should be updated to:
B4X:
'Template version: B4A-2.00
 
Upvote 0

MikeH

Well-Known Member
Licensed User
Longtime User
I am mighty impressed!

1779385409860.png


Is it possible to send only selected code, such as a sub?

Thank you Erel ❤️
 
Upvote 0

GeoffT660

Active Member
Licensed User
Longtime User
Will there be any issues with older apps not using B4xPages with a lot of code in Starter including Bluetooth code?
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I have this in my starter service
Starter Service:
Sub Process_Globals
    Private     logs                                     As StringBuilder
    Private     logcat                                     As LogCat

'    Private        mIsConnectedCalled                         As Boolean    = False
'    Private        mConnected                                As Boolean  = False

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.
    
    LogColor("Service_Create", Colors.Magenta)
    
'    '-------------------------------------------------------------------------------------
'    '    Erel's fix to handle Service crash
'    '-------------------------------------------------------------------------------------
'    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER   
    
'    IsDeviceFoldable


#if NeedServiceReceiver
        If     HttpUtils2Service.TempFolder = "" Then
            Dim jo As JavaObject
        
            jo.InitializeNewInstance(Application.PackageName & ".httputils2service", Null)
            jo.RunMethod("onReceive", Array(Null, Null))
        End If
#end if       
End Sub



Sub Service_Start (StartingIntent As Intent)   
    
'    Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
    
    logs.Initialize
            
    logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
    
    Service.StopAutomaticForeground
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.
Private Sub logcat_LogCatData (Buffer() As Byte, Length As Int)
            logs.Append(BytesToString(Buffer, 0, Length, "utf8"))
            
            If     logs.Length > 5000 Then
                logs.Remove(0, logs.Length - 4000)
            End If
End Sub


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

            LogColor($"Starter::Application_Error - Error:${Error.Message}"$, Colors.Red)
    return true
end sub

Can I move the logcat stuff to the main as well?
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
This was a B4A app that I created into a B4XPages app

In Application_Error I append the StackTrace to the Logs and attach that all to a Email I send to a specific email address that includes everything I know about the crash

I haven't changed anything here in years (works just fine whenever there is a crash)

It emails me info like this
Crash Info:
Logs
~L86156499969~-12303292:pFWEntries::B4XPage_Resize  -  Width:1340 Height:736 ~L96156565505~-16776961:pFWEntries::UI_Create  -  Width:1340 Height:736 ~L06156958721~-16711936:pFWEntries::Create_Screen -  Width:1340 Height:736
~l16156958851:LanePos-Width:66
~l26121897060:MainPanel (l/t) 407 / -51  (w/h) 526 / 839 ~l36121897079:EnteredInPanel (l/t) 6 / 337  (w/h) 513 / 330 ~l46121897083:EnteredIn (l/t) 6 / 51  (w/h) 500 / 279 ~L56168361985~-12303292:pFWReports::B4XPage_Resize  -  Width:1340 Height:736 ~L66168427521~-16776961:pFWReports::UI_Create  -  Width:1340 Height:736 ~L76168558593~-16711936:pFWReports::Create_Screen  -  Width:1340 Height:736 ~l86168558682:Option Button Sizes: 255 ~L96161415169~-12303292:pFWPayouts::B4XPage_Resize  -  Width:1340 Height:736 ~L06161546241~-16711936:pFWPayouts::Create_Screen -  Width:1340 Height:736 ~l16100401169:cPaySponsors-Init Root W/H: 1340 / 736 ~L26162725889~-16776961:pFWPayouts::Show_Data
~l39212205571:Error: page id not found: Billing
~l49212205572:Ids: (ArrayList) [mainpage, fwsetup, fwtypessetup, fwplayers, fwplayerssetup, fwentries, fwreports, fwreuse, fwscores, fwsponsors, fwstandings, fwstatistics, fwpayouts, bracedforimpact, subscriptions, contactsupport, findls, leaguepals, prizefund, userpreferences, scorecollectors]
~e:b4xpagesmanager_vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5 (java line: 604)
~e:java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.BOBs.BBS.b4xpagesmanager$_b4xpageinfo.B4XPage' on a null object reference in method 'java.lang.Object com.BOBs.BBS.b4xpagesmanager._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5(java.lang.String)'
~e:    at com.BOBs.BBS.b4xpagesmanager._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5(b4xpagesmanager.java:604)
~e:    at com.BOBs.BBS.main._do_resize(main.java:2171)
~e:    at java.lang.reflect.Method.invoke(Native Method)
~e:    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
~e:    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1167)
~e:    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1130)
~e:    at com.BOBs.BBS.main._check_for_resize(main.java:1082)
~e:    at java.lang.reflect.Method.invoke(Native Method)
~e:    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
~e:    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
~e:    at com.BOBs.BBS.main.onConfigurationChanged(main.java:3598)
~e:    at android.app.ActivityThread.performActivityConfigurationChanged(ActivityThread.java:6671)
~e:    at android.app.ActivityThread.performConfigurationChangedForActivity(ActivityThread.java:6574)
~e:    at android.app.ActivityThread.handleActivityConfigurationChanged(ActivityThread.java:6966)
~e:    at android.app.ActivityThread.handleActivityConfigurationChanged(ActivityThread.java:6899)
~e:    at android.app.servertransaction.ActivityConfigurationChangeItem.execute(ActivityConfigurationChangeItem.java:55)
~e:    at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
~e:    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
~e:    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
~e:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
~e:    at android.os.Handler.dispatchMessage(Handler.java:106)
~e:    at android.os.Looper.loopOnce(Looper.java:230)
~e:    at android.os.Looper.loop(Looper.java:319)
~e:    at android.app.ActivityThread.main(ActivityThread.java:8919)
~e:    at java.lang.reflect.Method.invoke(Native Method)
~e:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
~e:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
~L56192020482~-65536:Starter::Application_Error - Error:java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.BOBs.BBS.b4xpagesmanager$_b4xpageinfo.B4XPage' on a null object reference in method 'java.lang.Object com.BOBs.BBS.b4xpagesmanager._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5(java.lang.String)'


Stack Trace
java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.BOBs.BBS.b4xpagesmanager$_b4xpageinfo.B4XPage' on a null object reference in method 'java.lang.Object com.BOBs.BBS.b4xpagesmanager._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5(java.lang.String)'
    at com.BOBs.BBS.b4xpagesmanager._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5(b4xpagesmanager.java:604)
    at com.BOBs.BBS.main._do_resize(main.java:2171)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1167)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1130)
    at com.BOBs.BBS.main._check_for_resize(main.java:1082)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.BOBs.BBS.main.onConfigurationChanged(main.java:3598)
    at android.app.ActivityThread.performActivityConfigurationChanged(ActivityThread.java:6671)
    at android.app.ActivityThread.performConfigurationChangedForActivity(ActivityThread.java:6574)
    at android.app.ActivityThread.handleActivityConfigurationChanged(ActivityThread.java:6966)
    at android.app.ActivityThread.handleActivityConfigurationChanged(ActivityThread.java:6899)
    at android.app.servertransaction.ActivityConfigurationChangeItem.execute(ActivityConfigurationChangeItem.java:55)
    at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:230)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8919)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

End Logs

Like I said, I haven't changed this in years - Probably wrong now - but if we are getting rid of starter service then how do I handle crash information?

PS: Thanks for you help
 
Upvote 0

Tareq Khan

Member
Licensed User
Longtime User
I'm happy to release a new version of B4A. The integrated code bundle tool is now available in B4A (and B4J).
Code Bundle is a tool that packs your project together with additional relevant information into a single json file, that can be provided to AI assistants for debugging, learning, refactoring and other tasks.

B4A_kf7zblfSEr.gif


The bundle is created with a click of a button (Ctrl + R). The bundle includes:

  • Project code + list of public APIs. Keys are sanitized based on heuristic templates.
  • (optional) Logs + compilation output + warnings and errors list. Compilation output is included when the dialog is visible.
  • (optional) Layouts + designer script.
  • (optional) Paths configuration.
  • List of files. Files content is not added.
  • List of libraries with additional information for each library.
  • Manifest editor.
  • Current caret location with the code around it - the AI knows where you are focused on right now.
  • Additional information about the IDE and useful links for the AI to find more information.
How to use:
- Click on Ctrl + R. A json file will be created and copied to the clipboard. Paste into the AI assistant and ask questions.

Other improvements:
  • The Starter service is being deprecated due to restrictions applied by Android, which can lead to crashes in debug mode, and it becoming less useful with B4XPages. Removing the Starter service no longer affects the behavior of unhandled exceptions.
  • New warning in B4XPages projects when the starter service is included.
  • Application_Error sub can be added to the Main module (when the Starter service is excluded).
  • B4XPages project template updated accordingly.
  • #ExcludeCodeFromBundle attribute - set to True to exclude the current module from the code bundle. Note that public sub signatures and comments (before the subs only) will still be included in the bundle.
  • New log filter:

    View attachment 171493
    Error - includes the app logs and system level error logs. Very useful when looking for ANRs, startup errors and other mysterious crashes.
  • Autocomplete in #If lines.
  • List.Sublist - Very fast method that returns a read-only sub-list.
  • Fix for String.ToLower not explicitly setting the locale. Mainly fixes the Turkish I: https://www.b4x.com/android/forum/t...ctly-for-the-turkish-language.163961/#content
  • New #Macro / comment link options: (case insensitive)
    • librariesrefresh - set to True to automatically refresh the libraries after the task runs.
    • codesync - set to True to force the IDE to synchronize the code modules with the files.
    • autosave - set to True to automatically save the project BEFORE running the task. Note that Tools - IDE Options - Auto Save should be enabled for this to have effect.
    • filessync (not new) - set to True to synchronize the Files tab after the task.
    • cleanproject (not new) - set to True to "clean project" after the task
    • %STATE1% - new variable that causes the IDE to create a temporary file with the IDE state based on the new options under Tools - IDE Options. The file path will be passed to the process. This is used by Code Bundle and can be used by other similar tools. Note that the format can be modified in the future.
    • NoTimeout - set to True to disable the default process timeout (currently not available in B4J).
    • ide://KillProcesses - new option to kill all the currently running processes. Useful when running non-ui processes with no timeout (currently not available in B4J).

      Note that starting a B4J app as an external tool is as simple as:
      B4X:
      ide://run?File=<path to jar>\App.jar&NoTimeout=True
  • B4X Map collection can now wrap Java Maps.
  • Internal libraries updated.
  • Other bug fixes and minor improvements.
Download link: https://www.b4x.com/b4a.html
Whats the alternative of Starter service? Thanks
 
Upvote 0
Top