Other [new feature] b4x lib - a new type of library

Discussion in 'Android Questions' started by Erel, Dec 13, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    As B4X matures, more and more reusable components are written in B4X directly.
    In most cases it is simpler to implement the logic in B4X directly and the code can be cross platform. Especially with the relatively new XUI library.

    Standard libraries will never be cross platform as they are compiled to the platform native binary / bytecode. They also have other restrictions related to them being compiled.

    Starting with B4A (8.80), B4i (v5.50) and B4J (v7.00), a new type of libraries is available - b4x libraries.

    A b4x library is a simple zip file with:

    - Code modules. All types are supported including activities and services.
    - Files, including layout files.
    - Optional manifest file with the following fields:
    Version, DependsOn (list of required libraries), Supported Platforms. Fields can be shared between the platforms or be platform specific. For example:
    B4J.DependsOn=jXUI, jDateUtils
    B4A.DependsOn=XUI, DateUtils
    B4i.DependsOn=iXUI, iDateUtils
    Files and code modules can also be platform specific.

    Creating a b4x library is very simple. You just need to create a zip file with these resources. The zip file extension should be b4xlib. That's all.

    Note that the source code can be extracted from a b4x library.

    b4x libraries appear like all other libraries in the Libraries tab.

    Example of AnotherDatePicker custom view packaged as a b4x library is attached. It is cross platform and using it is a matter of clicking on the library in the list of libraries.

    Attached Files:

    Last edited: Jan 9, 2019
  2. DonManfred

    DonManfred Expert Licensed User

    !!! W-O-W !!! I like it! ;-)
    MarcoRome, asales, BillMeyer and 2 others like this.
  3. ocalle

    ocalle Active Member Licensed User

    This is going from best to best, congratulations.
  4. alwaysbusy

    alwaysbusy Expert Licensed User

    Very nice! As the source code is available in the zip, I even see some potential to use this to support BANano libraries... ;)
    amaxco, asales, Don Oso and 2 others like this.
  5. LucaMs

    LucaMs Expert Licensed User

    Very good new feature!

    B4X is growing!
    (unfortunately in the meantime I'm getting old :p:()
    KMatle, ocalle, Krammig and 7 others like this.
  6. f0raster0

    f0raster0 Active Member Licensed User

  7. Cableguy

    Cableguy Expert Licensed User

    I can forsee a major potential problem.
    If I understand correctly, any given user can simply unzip and play around with the code modules... If by doing so, the code gets broken, how can the "library" creator give support?
    This also means that B4X libs cannot be neither paid neither donation ware!(?)
    Krammig, ivan.tellez and FrostCodes like this.
  8. LucaMs

    LucaMs Expert Licensed User

    Yes, finally; as well as all the code you find on GitHub is free!

    Who wants to continue to earn "creating" libraries can always keep doing it for specific languages.
  9. sorex

    sorex Expert Licensed User

    Erel can always encrypt the source files inside these libs to offer some sort of 'protection'.
  10. keirS

    keirS Well-Known Member Licensed User

    Alternatively you give the library away but charge for support.
    amaxco likes this.
  11. ivan.tellez

    ivan.tellez Active Member Licensed User

    @Erel, as you can see in this few coments, it will be a lots of requests for offer support for some kind of encription. Can you add this? An option in the IDE to "Encrypt B4X library", ask for a password, so the same developper can decrypt it, but can be distributed without having to share the code.
    ocalle, Jmu5667, amaxco and 1 other person like this.
  12. johndb

    johndb Active Member Licensed User

    I think that the B4X Library feature will be a great enhancement to the B4X system. I'm in agreement with @ivan.tellez in that the code should be encrypted to protect the developer's investment and ability to support the library. I would also recommend that not only code be encrypted but all files (db and xls for example) be encrypted as well. In many cases, the data files embedded within the library ZIP can also be proprietary to the developer and/or the operation of library depends upon an unmodified known state of the data files.
    ocalle and ivan.tellez like this.
  13. asales

    asales Well-Known Member Licensed User

    I think this is a very good feature.
    There are so many old libraries in this forum that the developer don't give support and it is outdated (and I can't try to fix the problems).
    I think so this is not the only way to create libraries and If you want to create a library or wrap and sold/give support, you can use the old ways.
  14. johndb

    johndb Active Member Licensed User

    I think you are missing the point for this newly proposed B4X Library. This library is intended as a cross-platform library. Yes, the old way works but it has its limitations.
    ivan.tellez likes this.
  15. Erel

    Erel Administrator Staff Member Licensed User

    Cross platform is a very important advantage however it is not the only one. Other advantages:
    - Can include files and layout files.
    - Very simple to create.
    - Supports activities and services.
    - Libraries code can directly call external subs.
    - Conditional compilation is supported.
    - Source code is available for the developer who uses the library. Note that you can set any license that you like for the code.

    Encryption might be added in the future. It cannot be encrypted with a global key. Each encrypted library will have its own password.

    There are also advantages to the compiled libraries:

    - Can be referenced from native libraries. This is not possible with B4X libraries.
    - Source code not available.
  16. Erel

    Erel Administrator Staff Member Licensed User

    I've updated the tutorial. The extension of b4x libraries will be b4xlib and not b4x.zip. The zip extension can cause confusion.
  17. keirS

    keirS Well-Known Member Licensed User

    What would be really nice is a cross platform designer that just uses XUI components and saves a cross platform layout file.
  18. Eme Fibonacci

    Eme Fibonacci Well-Known Member Licensed User

    Maybe libraryname.b4x.lib instead of libraryname.b4xlib.
  19. LucaMs

    LucaMs Expert Licensed User

    I don't love "double extensions"; b4xlib is better, I think.
    jimmyF likes this.
  20. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    this will make things easier for sure thanx
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice