Android Tutorial B4ABuilder / B4JBuilder - Command line compilation

Erel

Administrator
Staff member
Licensed User
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:



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



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:

xiaoyao

Member
Licensed User
why show Signing package file (debug key)?

BuildConfiguration: Default,b4a.test1
Parsing code.
Compiling code.
Compiling layouts code.
Generating R file.
Compiling generated Java code.
Convert byte code - dex.
Packaging files.
'classes.dex'...
Copying libraries resources
Signing package file (debug key).
ZipAlign file.
Completed successfully: 4.58 seconds
 

Erel

Administrator
Staff member
Licensed User
why show Signing package file (debug key)?
It uses the same key that you set under Tools - Private Sign Key.

HOW TO USE "-Configuration"
The default value is DEFAULT. You can change to a different build configurations with: -Configuration=Free (assuming that you have created a build configuration named Free).
 

xiaoyao

Member
Licensed User
It uses the same key that you set under Tools - Private Sign Key.


The default value is DEFAULT. You can change to a different build configurations with: -Configuration=Free (assuming that you have created a build configuration named Free).
#AdditionalJar: javax
while can't compile?


B4A version 4.30 BETA 1
Parsing code. 0.00
Compiling code. 0.02
Compiling layouts code. 0.00
Generating R file. 0.03
Compiling generated Java code. 0.86
Convert byte code - optimized dex. Error
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.crimson.parser.ValidatingParser$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

Optimized dexer failed. Switching to Standard dexer.
 
Last edited by a moderator:

tchart

Active Member
Licensed User
Here is a batch file to wrap up your build. It flashes red if there is a compile error - otherwise it simply closes.

B4X:
@echo off

cd /d %0\..

SET Source_Dir="%CD%"
SET B4A_Builder=D:\Basic4android\B4ABuilder.exe

set errorlevel=

%B4A_Builder% -Task=Build > output.txt

IF "%errorlevel%"=="0" GOTO OK

IF "%errorlevel%"=="1" GOTO ERRORS



:OK

GOTO EXIT



:ERRORS

color FC

echo.

echo ******************************************

echo There were compile errors!

echo ******************************************

timeout /t 60 /nobreak



GOTO EXIT



:EXIT

cls

echo.

echo Done!

echo.
 

xiaoyao

Member
Licensed User
I ADD THE TOOLS.JAR copy from jdk path,14MB,IT'S ERR TO Compile,why?
java.lang.OutOfMemoryError: Java heap space



Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
at com.android.dx.ssa.Dominators$DfsWalker.visitBlock(Dominators.java:259)
at com.android.dx.ssa.SsaMethod.forEachBlockDepthFirst(SsaMethod.java:783)
at com.android.dx.ssa.Dominators.run(Dominators.java:185)
at com.android.dx.ssa.Dominators.make(Dominators.java:90)
at com.android.dx.ssa.DomFront.run(DomFront.java:86)
at com.android.dx.ssa.SsaConverter.placePhiFunctions(SsaConverter.java:297)
at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:51)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Optimized dexer failed. Switching to Standard dexer.
 

xiaoyao

Member
Licensed User
Why do you add tools.jar to your project?


Looks like a bug. Have you tried to set the output field?
TOOLS.JAR CAN Compile *.java file code to *.class ,in windows
but how can it do on android os?,i add this jar,and try ,you are great,i hope you can do it.

i find some android code ,and it can Compile *.class file to *.dex,how to *.JAVA TO *.CLASS?

YOUR corp MORE yers ,have ide soft in mobile ,for basic ,but this time,how can do a ide soft in android ?
can you give me some question?
 

xiaoyao

Member
Licensed User
when i try this ,it's show err,some times it't bad ,my app is out,stoped,i hope you can make a app on andnroid by BASIC CODE,YOU B4A IS ONLY 4MB SIZE ,i think you also can do a app for mobile.dose and method to Compile java code to *.class ?if it can java project path to apk,it's good.
 

DonManfred

Expert
Licensed User
every times ,you say like this ,you are a bad man!!!!
EVERY TIME YOU DO THE SAME AND POSTING ON THREADS ASKING QUESTIONS WHICH HAS NOTHING DO WITH THE THREADS SUBJECT!

And if erel than says that you should start a new Thread you say he do this every time.

The real question is:
Why the hell do you STILL asking in other threads instead of DIRECTLY create a new Thread like you should have learned before after erels state!?!?!?!?
Sounds for me like you are doing it wrong (always) and then making Erel responsible for your fault!? And then saying he is a bad man is absurd.

Erel is giving here the best support i ever saw in a community!


PS:
I like to welcome you on my IGNORE LIST!
 

Peter Simpson

Expert
Licensed User
Of course you should start a new thread in the ask a question part of this community. @xiaoyao how dare you call @Erel a "bad man", and what the hell are you doing saying "Lazy escape responsibility". Are you completely silly calling Erel lazy, he is by far the hardest working member of this community. There's an extremely high probability that you would have asked your question in the correct section of this community and that Erel would have answered it for you in that section. You need to learn to ask questions that are not related to the topic at hand in a new thread, it's as simple as that. Plus creating a new thread also makes it easier for others to help and answer your questions too. Also if another community member asks the same question in the future, they might find your post and hopefully find the answer to go with it.

Calling Erel lazy has got to be the dumbest comment that I've ever read in this community. The work that Erel does for all 69,000+ members of this community is absolutely outstanding and SECOND TO NONE.

You seriously owe Erel a huge apology for making up such a ridiculously outrageous statement, and for making up and claiming such BS allegations in this community of hard working B4X developers. Yes they are allegations that can easily be disproved just by reading previous posts in every single section bar none of this community.

Grow some balls and apologise profusely to Erel as your comments are 100% uncalled for and completely unrepresentative of the hard work that Erel puts into this B4X community.
 
Last edited:
Top