Android Tutorial B4ABuilder / B4JBuilder - Command line compilation

Discussion in 'Tutorials & Examples' started by Erel, Feb 2, 2015.

  1. Erel

    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:

    [​IMG]

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

    [​IMG]

    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.
     
  2. avacondios

    avacondios Active Member Licensed User

    Great !!!!!!!!!
     
  3. cambopad

    cambopad Active Member Licensed User

    This is the feature that I have been waiting for! Thanks you so much Erel :)
     
  4. xiaoyao

    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
     
  5. xiaoyao

    xiaoyao Member Licensed User

    HOW TO USE "-Configuration"
     
  6. Hexa

    Hexa New Member Licensed User

    Awesome thanks!
     
  7. Erel

    Erel Administrator Staff 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).
     
  8. xiaoyao

    xiaoyao Member Licensed User

    #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: Feb 9, 2015
  9. Erel

    Erel Administrator Staff Member Licensed User

    This is not related to this thread. Please start a new one instead.
     
  10. tchart

    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.

    Code:
    @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.
     
  11. thedesolatesoul

    thedesolatesoul Expert Licensed User

    When I use the following commandline:
    Code:
    C:\Programs\Basic4android\B4ABuilder.exe -BaseFolder=H:\MyProjects\B4A\MSMaterialDrawer
    It creates a file called MSMaterialDrawer.b4a instead of MSMaterialDrawer.apk?
    Not quite sure what causes that.

    [​IMG]
     
    Peter Simpson likes this.
  12. xiaoyao

    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.
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Why do you add tools.jar to your project?

    Looks like a bug. Have you tried to set the output field?
     
  14. thedesolatesoul

    thedesolatesoul Expert Licensed User

    After setting the output field it works fine. Without the output field though i expected the default extension to be apk.
     
  15. xiaoyao

    xiaoyao Member Licensed User

    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?
     
  16. xiaoyao

    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.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    @xiaoyao please start a new thread for this. It is not related to this thread.
     
  18. xiaoyao

    xiaoyao Member Licensed 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
     
  19. DonManfred

    DonManfred Expert Licensed User

    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!
     
  20. Peter Simpson

    Peter Simpson Well-Known Member 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: Mar 26, 2015
    Humberto and DonManfred like this.
Loading...