Android Tutorial Shared Code Modules

Discussion in 'Tutorials & Examples' started by Erel, May 8, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Edit: shared modules are still supported however more powerful options are available in newer versions of B4X:

    B4A v3.80 adds support for shared code modules.
    Shared code modules are modules (Activity, Service, Class or Static Code) that are stored in a specific folder and can be shared by multiple projects, similar to the way that libraries are shared.

    How it works

    When a project is loaded the IDE looks for the modules files (bas files) in the project folder. If the module file doesn't exist then the IDE will look for the module in the configured shared modules folder.

    The shared modules folder is set in the Paths Configuration dialog:


    You can see that a module was loaded from the shared folder in the list of modules (the icon with the small arrow):


    Adding a shared module to a project is done in the same way as adding a non-shared module.
    You choose Project -> Add Existing Module. If the module folder is the shared folder then the module will be loaded as a shared module and will not be copied to the project folder.

    If you want to convert a non-shared module to a shared module then you need to manually move the module file to the shared modules folder and reload the project
    Last edited: Jun 19, 2018
    Azam Memon, mrred128, Theera and 19 others like this.
  2. klaus

    klaus Expert Licensed User

    That's really good news.
    I was hoping for this already with Basic4PPC.
    This shows that sometimes dreams become reality :).
  3. shashkiranr

    shashkiranr Active Member Licensed User

    This is very helpful Erel. :) Thank you so much :)
  4. Peter Simpson

    Peter Simpson Expert Licensed User

    That's definitely useful, thanks @Erel
  5. MaFu

    MaFu Well-Known Member Licensed User

    Great news :)
  6. gawie007

    gawie007 Member Licensed User

    This is more like what I have been needing!
    Brilliant work!
  7. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

  8. JoanRPM

    JoanRPM Active Member Licensed User

    Good job!
  9. belangelot

    belangelot New Member Licensed User

    Very clever !
  10. laviniut

    laviniut Active Member Licensed User

    Great idea!
  11. AscySoft

    AscySoft Active Member Licensed User

    Nice, but what is the advantage by using shared modules vs IDE modules?
  12. Erel

    Erel Administrator Staff Member Licensed User

    It is not shared modules vs. IDE modules. The IDE can load modules from two locations: the project folder and the new shared modules folder.

    If you like to share the same code file between different projects then you should put the module file in the shared modules folder.
  13. psciga

    psciga Active Member Licensed User

    Thank you very much!!!
  14. gudino jose luis

    gudino jose luis Active Member Licensed User

    Thank you very much!!!
  15. Dominex

    Dominex Active Member Licensed User

  16. namnach

    namnach Member Licensed User

    This is very fine thinking - so "template" ( network, server, client .. ) can make for each Projects.
    Thank you - !
  17. GMan

    GMan Well-Known Member Licensed User

    Great Option :)
    Is the same possible for .BALs ? :rolleyes:
  18. Erel

    Erel Administrator Staff Member Licensed User

    Currently no...
  19. klaus

    klaus Expert Licensed User

    Would be very useful !
    I use a shared About module which has a dedicated bal file.
    It would be very useful to share the bal file the same way as the module file.
  20. cambopad

    cambopad Active Member Licensed User

    Nice feature!
  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