A better tutorial:
https://www.b4x.com/android/forum/threads/banano-v2-2-b4j-abstract-designer.101544
-----------------------------------------------------------------------------
In version 1.11+, you can create BANano libraries. This improves the cluther of files in your project.
Note: this does not (yet) use the new library system
@Erel introduced yesterday with the .b4x.zips!
How it works:
Write your code as normal. Everything but the 'main' module will be included in the library. Instead of using the BANano.Build() method, you use the BANano.
BuildAsLibrary() method.
Procedure to make a lib is quite simple (order is somewhat important as step (1) also makes a .jar file, which you should ignore).
1. Run your project in
Release mode: it will generate the BANAnoLeaflet.js and a BANAnoLeaflet.dependsOn files
2. Compile your project 'To Library' in the B4J IDE. The name of the lib
MUST be the same as the project name of the library (*)
Using the new lib:
1. Copy all 4 files (.jar, .xml, .js, .dependsOn) to your B4J Additional Libraries folder
2. Add the new library to your application
I think this is a rather elegant solution and of course, your 'real' project using the library is a lot cleaner.
Note:
@Kiffi had a great suggestion on class and library naming.
I strongly advice you to follow this as it will decrease the chance of having incompatible BANano libraries!
1. Name your classes according to this scheme
BANano[
JsLibName][JsClassName]
2. Name your library
BANanoJ
sLibName
For example, you make a library 'GoogleMaps':
Classes/modules in your lib:
Code:
BANanoGoogleMapsClass1
BANanoGoogleMapsClass2
BANanoGoogleMapsModule1
Name of your library project (and jar, xml, ...):
This will make it a lot easier for everyone to identify a BANano library among all the other B4J libs and it will avoid having two libraries having the same class names and (maybe) interfering with each other.
The Leaflet library of
@Kiffi shows a great example of this principle.
I can only hope more forum users get enthusiastic enough to build BANano libraries and share them with the community. So
Let's all go BANanos!
Alain