Does adding libraries add ALL the library code.

barx

Well-Known Member
Licensed User
Longtime User
good day everyone.

Just a quick question, When I add a library to my project does all the library code get added to my final app / apk or is it just the functions that are used. My app uses quite a few libraries and the final APK is larger that I thought it would be >1.3mb. Just wondering if its due to library use or not.

Thanks.
 

R Rioja

Member
Licensed User
Longtime User
It's too bad that B4A does it that way. It defeats the whole purpose of a library. When you walk into a library, you check out one or two books and take them home. You don't walk out with every book in the building. B4A should, at compile time, take what it needs and leave the rest behind.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It defeats the whole purpose of a library.
Not at all. Without libraries the "core" library would have included all the APIs. By using libraries you can select only the libraries you need. The same thing happens in Java when you reference a Jar file and in C# when you reference a DLL and in other programming languages.
The compiler cannot really know which classes inside the libraries are required.

In most cases the size of a single bitmap will be more than the size of all the libraries you add.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
It's too bad that B4A does it that way. It defeats the whole purpose of a library. When you walk into a library, you check out one or two books and take them home. You don't walk out with every book in the building. B4A should, at compile time, take what it needs and leave the rest behind.
It kind of does work like that. B4A picks the libraries you checked out in the libraries tab, it doesnt include all of them.
However, from the check out libraries, whether you use the code or not, the code does get included. Like the one or two books you do take home, whether you read all the pages or not, you have to take the whole book.
 
Upvote 0
Top