Android Code Snippet Batch file for compiling multiple projects

The following code is an example of how to use the command line tool to compile all projects contained in folders below the folder which holds this batch file. Save it with a .bat extension and double-click to run. It writes a summary of the results to a file called result.txt and the details of each compilation to detail.txt.

Note that if the -Output parameter is not specified then no APK file will be produced.

REM Compile projects in all folders below this one

REM B4ABuilder.exe Parameters:
REM -Task: What you want to do. Possible values:
REM   Build - Similar to Release compilation (default value)
REM   BuildLibrary - Similar to Library compilation.
REM -BaseFolder: The project folder. Default value is the current folder.
REM -Project: Main project file. Can be omitted if there is only one b4a file in the base folder.
REM -NoSign: If True then the APK is not signed. Similar to Compile without signing option.
REM -Obfuscate: If True then the compiled APK will be obfuscated.
REM -ShowWarnings: Whether to list the compilation warnings.
REM -Configuration : Build configuration.
REM -Optimize : Whether to include an optimization step during the byte conversion (dexer).
REM -NoClean : Whether to skip the project cleaning step.
REM -Output : Compiled APK name (does not affect libraries builds).

SET b4abuilder="C:\Program Files (x86)\Anywhere Software\Basic4android\B4ABuilder.exe"

REM Initialize output files
ECHO Starting New Run %time% %date% > detail.txt
ECHO Starting New Run %time% %date% > result.txt

FOR /D %%i IN (*) DO (
ECHO === Compiling %%i === >> detail.txt
REM ECHO %b4abuilder% -Task=build -BaseFolder=%%i -Output=%%i.apk >> outputb4a.txt
%b4abuilder% -Task=build -BaseFolder=%%i -Output=%%i.apk >> detail.txt

  echo %%i Failed >> result.txt
  ) ELSE (
  echo %%i Succeeded >> result.txt
Last edited:


Well-Known Member
Licensed User
Longtime User

It's good to know that I'm not the only one who remembers the ancient art of batch programming!