Android Question Conditional inclusion of a B4A Library

Derek Johnson

Active Member
Licensed User
Longtime User
I would like to conditionally include a regular B4A library, say FusedLocationProvider, so that I can omit it in builds that do not require it but include it when needed.

Erel suggested that it would involve using

B4X:
#If FLP  
    #AdditionalJar: FusedLocationProvider
#End if
So I omitted FusedLocationProvider from the list of libraries, hoping that would work.
However if I do that then this statement fails to compile:
B4X:
#If FLP
    Dim FLP1 As FusedLocationProvider
#End If

B4A version 4.30
Parsing code. Error
Error parsing program.
Error description: Unknown type: fusedlocationprovider
Are you missing a library reference?
Occurred on line: 28
Dim FLP1 As FusedLocationProvider
So not quite so simple as I hoped. However I've heard that there might be a solution :)
hopefully not too complicated!

It seems like what is needed is a conditional deletion of a jar/library file at compile time, so that the editor still recognises the elements of an included library but then they are removed before compilation.

Derek
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
The FusedLocationProvider library itself is quite small (less than 100kb). The problem is that it depends on google-play-services.jar which is a large jar (3m+).

The solution is:
1. Edit FusedLocationProvider.xml and remove the DependsOn line (near the bottom).
2. Keep the library checked in the IDE.
3. Conditionally add google-play-services.jar with #AdditionalJar: google-play-services
 
Upvote 0
Top