Android Question Conditional inclusion of a B4A Library

Discussion in 'Android Questions' started by Derek Johnson, Jun 5, 2015.

  1. Derek Johnson

    Derek Johnson Active Member Licensed 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

    Code:
    #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:

    Code:
    #If FLP
        Dim FLP1 As FusedLocationProvider
    #End If

    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: Jun 5, 2015
  2. Erel

    Erel Administrator Staff Member Licensed 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
     
    moster67 and Derek Johnson like this.
Loading...
  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