Starting from Basic4android v2.50 you can compile your project, or part of it to a regular library.
Why should I compile a library?
The output of library compilation are two files: a jar file with the compiled code and a xml file that includes the metadata that is required by the IDE.
These two files should be saved in one of the libraries folders.
Compiling to a library is quite simple. Under Project menu there is a new compile option - "Compile To Library (Alt + 5)". When you choose this option all the modules except of the main activity are compiled into a library.
You can exclude other modules as well with the ExcludeFromLibrary attribute (see this tutorial for more information about attributes).
The main activity and the other excluded modules can be used to test the library.
You can reference the library from other projects and access the same functionality as in the original project.
Library specific attributes
The following attributes are specific for library compilation:
Project attributes (placed in the main activity):
LibraryVersion - A number that represents the library version. This number will appear next to the library name in the libraries list.
LibraryAuthor - The library author. This value is added to the library xml file.
LibraryName (B4A v2.70) - The compiled library name. Sets the library name instead of showing the save dialog.
All modules:
ExcludeFromLibrary - Whether to exclude this module during library compilation. Values: True or False. Note that the Main activity is always excluded.
Classes:
Event - Adds an event to the list of events. This attribute can be used multiple times. Note that the events list only affects the IDE events autocompletion feature.
Notes
- You should right click on the libraries list and choose Refresh after an update when updating a referenced library..
- CallSub / CallSubDelayed - The first parameter for these keywords is a reference to the target module. When working with modules that reside in a library you should pass the module reference and not the module name as string (this is the better way to reference all modules in all cases).
- Code obfuscation - Libraries can be obfuscated during library compilation. Strings will not be obfuscated in this mode.
- Services that host home screen widgets cannot be compiled into a library.
Why should I compile a library?
- Break large projects into several smaller (more maintainable) projects.
- Build reusable components and use them from any number of projects.
- Share components with other developers without sharing the source code.
- Create different versions of your application (free, pro...) by referencing the same "core" library.
The output of library compilation are two files: a jar file with the compiled code and a xml file that includes the metadata that is required by the IDE.
These two files should be saved in one of the libraries folders.
Compiling to a library is quite simple. Under Project menu there is a new compile option - "Compile To Library (Alt + 5)". When you choose this option all the modules except of the main activity are compiled into a library.
You can exclude other modules as well with the ExcludeFromLibrary attribute (see this tutorial for more information about attributes).
The main activity and the other excluded modules can be used to test the library.
You can reference the library from other projects and access the same functionality as in the original project.
Library specific attributes
The following attributes are specific for library compilation:
Project attributes (placed in the main activity):
LibraryVersion - A number that represents the library version. This number will appear next to the library name in the libraries list.
LibraryAuthor - The library author. This value is added to the library xml file.
LibraryName (B4A v2.70) - The compiled library name. Sets the library name instead of showing the save dialog.
All modules:
ExcludeFromLibrary - Whether to exclude this module during library compilation. Values: True or False. Note that the Main activity is always excluded.
Classes:
Event - Adds an event to the list of events. This attribute can be used multiple times. Note that the events list only affects the IDE events autocompletion feature.
Notes
- You should right click on the libraries list and choose Refresh after an update when updating a referenced library..
- CallSub / CallSubDelayed - The first parameter for these keywords is a reference to the target module. When working with modules that reside in a library you should pass the module reference and not the module name as string (this is the better way to reference all modules in all cases).
- Code obfuscation - Libraries can be obfuscated during library compilation. Strings will not be obfuscated in this mode.
- Services that host home screen widgets cannot be compiled into a library.