Android Question include/exclude library based on build configuration

corwin42

Expert
Licensed User
Longtime 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?
 

Computersmith64

Well-Known Member
Licensed User
Longtime 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?
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:

B4X:
#If FREEorAMAZON
        Private adMob As InterstitialAd
        Private prevVolume As Int
 #End If

- Colin.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime 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.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime 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.
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.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime 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.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime 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.
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.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
He is using two different build configurations. It is currently not possible to add or remove libraries based on the selected build configuration
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.
 
Upvote 0
D

Deleted member 103

Guest
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.
Did you try this configuration in Google Play Console?

upload_2019-5-10_12-14-46.png
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
Did you try this configuration in Google Play Console?
Yes.

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.

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.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Did you try this configuration in Google Play Console?

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.
 
Upvote 0
Top