Other B4A v13.5 BETA - integrated code bundle and more

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm happy to release a new BETA 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. 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.
  • New log filter:

    1778677099278.png

    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.
  • Other bug fixes and minor improvements.
Download link: https://www.b4x.com/android/files/beta.exe
 

ema01

Active Member
Licensed User
Longtime User
The Starter service is being deprecated due to restrictions applied by Android, which can lead to crashes. Removing the Starter service no longer affects the behavior of unhandled exceptions.
Where should i put then objects that need to live *forever* in a non-B4XPages project?
For example: Localizator
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I wanted to revisit a suggestion I made earlier regarding CodeBundle and AI export support:


First, I really like the new integration of CodeBundle directly into the B4A IDE. I think this is a very smart addition and can become extremely useful for AI-assisted development, debugging, and project analysis.

However, I still have a few concerns and suggestions:

1. I would like the ability to explicitly exclude additional code/data from the generated JSON — not just API keys. There are many situations where developers may want to hide proprietary logic, internal comments, credentials, customer-specific code, licensing logic, URLs, SQL, or other sensitive sections from AI analysis.

2. While the current template filtering for API keys is helpful, I personally would not feel fully comfortable relying solely on pattern/template matching to guarantee sensitive code is removed correctly. A missed match could unintentionally expose code or credentials to an external AI service.

Because of that, I still think an explicit compiler directive or exclusion mechanism would be safer and more flexible. Something like:

#If Not(CodeBundle)
' Sensitive code here
#End If

or any equivalent exclusion feature that guarantees specific sections are never exported into the JSON bundle.

I also think this could help with another important issue: AI context size limits. Some projects may simply be too large for an AI to analyze effectively in a single request. An exclusion mechanism could allow developers to intentionally omit large sections, helper modules, generated code, or even entire modules that are not relevant to the current AI discussion, keeping the generated JSON smaller and more focused.

Additionally, I think the compiler directive name itself ("CodeBundle") should ideally be a reserved/built-in conditional symbol automatically enabled whenever the CodeBundle feature is used, regardless of the current build configuration.

The reason is safety and reliability. I would not want to depend on manually switching to a special build configuration that defines a custom conditional symbol before generating the JSON. It would be very easy to accidentally run CodeBundle using the wrong build configuration and unintentionally expose code that was supposed to be excluded.

If "CodeBundle" were automatically defined internally by the IDE/compiler whenever the CodeBundle process runs, then the exclusions would always work correctly and automatically with no extra steps required from the developer.

Additional advantages of an explicit CodeBundle exclusion/compiler-directive approach:

* Helps protect sensitive information, proprietary business logic, credentials, licensing systems, and intellectual property from accidental AI exposure.
* Reduces generated JSON size, helping with AI token/context limits, faster processing, and lower AI costs.
* Improves AI analysis quality by excluding unrelated modules, helper code, generated code, and other unnecessary project context.
* Makes enterprise/corporate usage more practical by supporting stricter security, compliance, and auditing requirements.

I think features like this would greatly increase both developer confidence and practical usability of CodeBundle with AI tools.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Where should i put then objects that need to live *forever* in a non-B4XPages project?
For example: Localizator
The new warning is limited to B4XPages projects for this reason. In non-B4XPages projects the starter service serves a function that is not simple to replace. This is not the case with B4XPages.
The issues with the starter service seems to be limited to debug sessions so I wouldn't classify them as critical at this point.

Overall the direction of Android in related to services is quite clear. They become more restricted and problematic with each update of Android.
 
Upvote 0

ema01

Active Member
Licensed User
Longtime User
The issues with the starter service seems to be limited to debug sessions so I wouldn't classify them as critical at this point.
are you referring to the issuse that the app doesn't start the first debug session of the day?

Overall the direction of Android in related to services is quite clear. They become more restricted and problematic with each update of Android
Yep, too bad we have special use cases that require foreground services running forever (we keep getting the clearance, for now...)
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
deprecation of the Starter Service can have quite an impact on projects that started long time ago.
if the issue is really limited to debug sessions and not affecting the release, it can be manageable.
a whole different matter would be if this is an anticipation of some (future?) Android release restriction
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
are you referring to the issuse that the app doesn't start the first debug session of the day?
Probably. It can happen when the screen is turned off while you run the app. A more serious issue is with ANR during debugging that is caused by the starter service.

Let me clarify that the starter service behaves exactly the same in this new version. The changes are:
1. A warning in B4XPages project, where the starter service is less needed any way.
2. Better error handling when the starter service is excluded.
 
Upvote 0

virpalacios

Active Member
Licensed User
Longtime User
Wow Erel, you make my wish come true, !!!!B4A Code Bundle!!! 👍 😄👋👋👋👋 , Always very good things from you,

Very Best Regards 👏
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Probably. It can happen when the screen is turned off while you run the app. A more serious issue is with ANR during debugging that is caused by the starter service.

Let me clarify that the starter service behaves exactly the same in this new version. The changes are:
1. A warning in B4XPages project, where the starter service is less needed any way.
2. Better error handling when the starter service is excluded.
So, for non B4XPages projects, we can still use the starter server ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
So, for non B4XPages projects, we can still use the starter server ?
You can use the starter service in all types of projects. Nothing has changed regarding its behavior.

We are seeing issues related to the starter service with latest versions of Android. Currently only during debug mode.
My recommendation is to stop using the starter service with B4XPages, where it isn't really needed anyway.
 
Last edited:
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
You can use the starter service in all types of projects. Nothing has changed regarding its behavior.

We are seeing issues related to the starter service with latest versions of Android. Currently only during debug mode.
My recommendation is to stop using the starter service with B4XPages, where it isn't really needed anyway.
Thanks for being very clear on this !
 
Upvote 0

AhmetKeller

New Member
Licensed User
Longtime User
Great update Erel, thank you!

The integrated Code Bundle feature looks extremely useful for AI-assisted development workflows.
Really smart and practical addition.
Great work as always.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
testing Beta on compile I get this error
Could not find a part of the path 'C:\Users\locki\Documents\LARA5\B4A\Objects\b4xlibs\Files\b4xinputtemplate.bal'.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
in my app I have created a VIN decoder and lines like below are picked up by the code bundle tool and removed

Dim yearMap As String = "VWXY123456789ABCDEFGHJKLMNPRST"
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
in my app I have created a VIN decoder and lines like below are picked up by the code bundle tool and removed
This is fine and expected.

testing Beta on compile I get this error
Could not find a part of the path 'C:\Users\locki\Documents\LARA5\B4A\Objects\b4xlibs\Files\b4xinputtemplate.bal'.
More information please. Does the same project compile with previous version of B4A? Are you able to reproduce it in a small project?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I wanted to revisit a suggestion I made earlier regarding CodeBundle and AI export support:
The stable version will include a new #ExcludeCodeFromBundle attribute which will cause the code of that module to be excluded. Note that public sub signatures and comments (before the sub only) will still be included in the bundle.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
The stable version will include a new #ExcludeCodeFromBundle attribute which will cause the code of that module to be excluded. Note that public sub signatures and comments (before the sub only) will still be included in the bundle.
Thank you, Erel. I appreciate you adding more module-level control to CodeBundle.

Is there a technical reason why a more granular inline conditional approach, such as `#If / #End If`, would not be possible for CodeBundle exclusions?

The new `#ExcludeCodeFromBundle` attribute is definitely useful, but being module-level only seems more limiting than an inline conditional symbol such as:

#If Not(CodeBundle)
' Code that should not be exported to the bundle
#End If

With an inline approach, we could still exclude an entire module by placing `#If Not(CodeBundle)` at the top of the module and `#End If` at the bottom. But we would also have the added flexibility of excluding only a few sensitive lines, a single method, or a specific code region while still allowing the rest of the module to be included for AI analysis.

Another concern is that a module-only method may require the developer to reorganize an existing project just to move all code/info that should be hidden from the AI into separate modules. That could break or disrupt the natural organization of related code by forcing sensitive pieces into unrelated fragments simply so they can be excluded from the bundle.

Some examples where granular control would be useful:

* Excluding only credentials, private URLs, SQL connection strings, or customer-specific constants inside an otherwise useful module.
* Excluding licensing, activation, anti-piracy, or proprietary algorithm sections while still sharing the surrounding code structure.
* Excluding a single method that contains sensitive business logic while keeping the public/helper methods available to the AI.
* Excluding large generated sections, lookup tables, embedded data, or test/debug code inside a module without hiding the whole module.
* Excluding internal comments or notes that should not be sent to an AI while keeping the actual code visible.
* Keeping related code together in the source project instead of restructuring modules only to satisfy the export mechanism.
* Keeping the AI context more useful by sharing most of a module instead of forcing an all-or-nothing module exclusion.

My concern is that module-level exclusion may often remove too much useful context from the AI, while still not allowing precise removal of the specific lines or regions that the developer actually wants to keep private.

So I think `#ExcludeCodeFromBundle` is a good improvement, but an automatic built-in `CodeBundle` conditional symbol would provide more flexible and safer control.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I have nothing against such an option. There is a "small" technical challenge here related to the simple parser implemented in the code bundle tool, though it can be of course improved.

The code bundle is a new feature and adding more options is always possible. Removing options is problematic.
As we all gain more experience with it, we might realize that other features are missing and then decide to solve them together differently. We will need to wait and learn...
 
Upvote 0
Status
Not open for further replies.
Top