Android Tutorial B4ABuilder / B4JBuilder - Command line compilation

B4A v4.30 includes a new tool named B4ABuilder.exe (and B4J includes a similar tool named B4JBuilder.exe).

This tool allows you to compile your projects from the command line. This can be useful if you need to build multiple projects or to build the same project with multiple configurations.

It supports two tasks: Compiling to APK and library compilation (same option as in the IDE).

Using this tool is quite simple.
If you just run B4ABuilder.exe you will get the list of commands:

1618725685389.png


Add -Task=build to build the project in the current folder:

SS-2015-02-02_16.51.46.png


You can change the base folder with the BaseFolder parameter.

The builder will exit with a code of 0 if the operation completed successfully. If not the exit code will be 1.

Edit: There is an open issue with BaseFolder. Don't use this parameter for now.
 
Last edited:

wonder

Expert
Licensed User
Longtime User
B4X:
B4A version: 6.31
Parsing code.                       ( 0.38s)
Compiling code.                     ( 0.25s)
Compiling layouts code.             ( 0.00s)
Organizing libraries.               ( 0.00s)
Generating R file.                  ( 0.20s)
Compiling generated Java code.      ( 2.54s)
Convert byte code - optimized dex.  ( 1.98s)
Packaging files.                    ( 0.77s)
Copying libraries resources         ( 2.03s)
    Found 23 resource files.        
Signing package file (private key)  ( 1.55s)
ZipAlign file.                      ( 0.39s)
Installing file to device.          (12.68s)
    Device serial: 127.0.0.1:21503
Completed successfully.

It's not slow at all, but some extra-speed is always welcome! :D
 

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Hello all,

Anyone have this error? How is possible B4Abuilder identify the B4A file on the summary and bnot when compiling?
It sounds like the parameter -BaseFolder not working (-BaseFolder=)

C:\Program Files (x86)\Anywhere Software\Basic4android>B4ABuilder.exe -task=Build -obfuscate=False -BaseFolder=C:\Agent\_work\3\s\B4A -Configuration=GooglePlay -Project=PetSitter.b4a
B4ABuilder v9.01.2
Java version: 8
BaseFolder: C:\Agent\_work\3\s\B4A
ProjectFile: PetSitter.b4a

System.IO.FileNotFoundException: Could not find file 'C:\Program Files (x86)\Anywhere Software\Basic4android\PetSitter.b4a'.
File name: 'C:\Program Files (x86)\Anywhere Software\Basic4android\PetSitter.b4a'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at dg.p(FileMode A_0, FileAccess A_1)
at cf.l()
at cf.j(String[] A_0)
at cf.m(String[] A_0)
Could not find file 'C:\Program Files (x86)\Anywhere Software\Basic4android\PetSitter.b4a'.

upload_2019-6-3_12-7-28.png


Even with this simple command:
B4X:
B4ABuilder.exe -task=Build -BaseFolder=C:\Agent\_work\3\s\B4A\

@Erel You change something on this B4ABuilder v9.01.2??

*Update*
I saw the problem, the folder /B4A after my last directory is ignoring by builder, this is correct?
 
Last edited:
Top