Android Question include/exclude library based on build configuration

Discussion in 'Android Questions' started by corwin42, May 8, 2019.

  1. corwin42

    corwin42 Expert Licensed User

    Google complained about one of my apps that it is misusing the Google advertising Id.
    The problem is that this app does not use any ads at all but it is compiled with FirebaseAdmob library activated because there is a build configuration for a free version which uses ads.

    Is there a possibility to exclude a library based on the build configuration?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use #ExcludeClasses to remove the classes from the compiled APK. You probably need:
    Code:
    #if Not(Free)
    #ExcludeClasses: .ads
    #end if
     
    DonManfred, corwin42 and MarcoRome like this.
  3. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    I have a couple of apps that have multiple build configurations (Free, Paid & Amazon) & with those I just manually add/remove the relevant libraries. In the code, I make sure that I'm not compiling in any code relevant to the removed libraries by using #If #End If blocks for the different build configurations, eg:

    Code:
    #If FREEorAMAZON
            Private adMob As InterstitialAd
            Private prevVolume As Int
     
    #End If
    - Colin.
     
  4. corwin42

    corwin42 Expert Licensed User

    @Computersmith64 This is not enough. Google scans the .apk. If the FirebaseAdmob library is added to the apk they may complain about it if you don't have a privacy policy. No matter if you use the library or not. I think Erels approach will work. This removes the ads libraries from the apk.
     
  5. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Of course it's enough. I remove the library manually & conditionally exclude related code from the compile. The library doesn't come up in a scan because it's not included in the .apk. I've been doing this for years with a couple of apps.

    FYI - if you do happen to accidentally include the admob library in an app that you have said doesn't have ads, you'll just get a warning in your developer console saying that if your app does show ads it may be removed.

    - Colin.
     
  6. corwin42

    corwin42 Expert Licensed User

    All I can say is that my app was removed from the playstore because of this. It does not show any ads but only has the FirebaseAdmob library included. Maybe you had luck until now.
     
  7. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    I don't think you're understanding what I'm saying. For the builds of the apps that don't show ads (ie: the paid versions), I remove the library from the libraries list in B4A & conditionally compile out any references to code that use that library in the free & amazon versions (which do show ads). So there is no FirebaseAdmob library in the paid version.

    Why would you include the FirebaseAdmob library in an app that doesn't show ads?

    - Colin.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    He is using two different build configurations. It is currently not possible to add or remove libraries based on the selected build configuration
     
  9. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Yes I understand that, but it's easy to remove entire libraries when switching build configurations prior to compiling.

    I agree that in an ideal world it would be great to be able to conditionally compile in/out libraries, but it doesn't take much to select/deselect them in the libraries list - & if you conditionally include/exclude the related code you don't have to change anything else.

    - Colin.
     
    jimmyF likes this.
  10. Filippo

    Filippo Expert Licensed User

    Did you try this configuration in Google Play Console?

    upload_2019-5-10_12-14-46.png
     
    Computersmith64 likes this.
  11. corwin42

    corwin42 Expert Licensed User

    Yes.

    I know that I can manually remove the library before I compile my app in the configuration which does not use any ads. But I have 6 build configurations with some needing some ad libraries, others not.
    My question in the first post was if there is a possibility to do this library handling automatically while switching build configurations.
    Erel posted the correct solution (as a workaround) in his first answer. This solution will work for me and we don't need to discuss the topic any longer.
     
  12. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Thanks @Filippo - I knew I'd seen that somewhere! Per the message, I've always just left it as-is & never had an issue with it. I probably should just remove the library like I do in my other paid apps, but I haven't been actively updating this app for some time.

    Screen Shot 2019-05-11 at 8.00.52 AM.png
    - Colin.
     
  13. Filippo

    Filippo Expert Licensed User

    My last update is 30.03.2019 and it does not cause any problems. :)
     
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