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:

Erel

B4X founder
Staff member
Licensed User
Longtime User
every times ,you say like this ,you are a bad man!!!!
Lazy escape responsibility, not as badly, settle a matter by leaving it unsettled

Why is it so difficult to start a new thread? This forum is more than a place to post questions. It is a knowledge base.

The only way for information to be discoverable and useful is if we discuss each question in its own thread.

Anyway, I'm sorry but I will not answer to any of your questions in the future.
 

DonManfred

Expert
Licensed User
Longtime User
Anyway, I'm sorry but I will not answer to any of your questions in the future.
You dont need to be sorry for this. It is such a people that let me considering to NOT release any FREE Library in future

I need a way to put my name of his ignore-list so he can not see any new Libraryposting from me. And he will not buy a library too. I dont want to get paid from such peoples :D
 

igvas

New Member
Licensed User
Longtime User
I'm using B4ABuilder to build 3 configurations.
One of them have different Manifest content, based on precompiled vars (KIOSK is one of them).
This is the command line from target build script:

CALL %B4ABUILDER% -task=Build -obfuscate=True -NoClean=False -output=%OUTPUTFILE% -baseFolder=..\ -configuration=%1

This is the part of Manifest editor text:

#if KIOSK
AddActivityText("Main",
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
)
#End If

"KIOSK" configuration must have additional lines in AndroidManifest.xml

But in build-time content of AndroidManifest.xml is not changes.
It changes only after open and then close manifest editor dialog.
This behavior do not allow to me use batch build.

Can anyone help me?
 

igvas

New Member
Licensed User
Longtime User
With version 5.00 all works as expected.
Thank you for timely release!
 

Andre Souza

Member
Licensed User
I used this command and it does not generate the apk . I am using file temp_a file to sign . It's correct?

C:\Program Files\Anywhere Software\Basic4android\B4ABuilder.exe" -task=build -nosign=true

How use o command Output.
Output=name.apk not working
 

Andre Souza

Member
Licensed User
Thank You
How to reduce the apk. the signed file with B4A is around 2.5MB. Unsigned with is 2.8 MB. Is there any command from the command line to reduce. I've tried to put the key in B4A but the error. The solution was manually sign
 

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Erel,

The -Output for B4ABuilder.exe parameter is not working?

The APK is generate with success, but in the /Objects folder and not the specific output folder

I tried this commands and no one works:

B4ABuilder.exe -Task=Build -obfuscate=False -BaseFolder=C:\Users\iglesias\Desktop\1.0 -Output=C:\TEMP
B4ABuilder.exe -Task=Build -obfuscate=False -BaseFolder=C:\Users\iglesias\Desktop\1.0 -Output=C:\TEMP\test.apk
B4ABuilder.exe -Task=Build -obfuscate=False -BaseFolder=C:\Users\iglesias\Desktop\1.0 -Output=C:\\TEMP
B4ABuilder.exe -Task=Build -obfuscate=False -BaseFolder=C:\Users\iglesias\Desktop\1.0 -Output=C:\\TEMP\\test.apk

I do something wrong?

Thanks

Alberto Iglesias
 

Ferraz71

Member
Licensed User
Longtime User
i have a problem.....

what is wrong?

c:\Arquivos de Programas\basic4android50>b4abuilder -BaseFolder="c:\users\rogerio\desktop\mectro\basic android\cmd\rootcmddemo" -Task=Build -NoSign=true
B4ABuilder v5.50
BaseFolder: c:\users\rogerio\desktop\mectro\basic android\cmd\rootcmddemo
ProjectFile: rootcmd.b4a
BuildConfiguration: Default,ice.rootcmddemo
Parsing code.
Compiling code.
Compiling layouts code.
Generating R file.
Compiling generated Java code.
Convert byte code - dex.
System.Exception: Error: UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
10 errors; aborting

em c6.a(a A_0)
em br.i(String[] A_0)
em br.l(String[] A_0)
Error: UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.NullPointerException
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:217)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
10 errors; aborting
 
Top