I am trying to figure it out how to publish my app on AppGallery and Google Play. (My app is currently available on Google Play)
I am researching it for three hours and the best option looks like using flavors. Because I want to use same code base for different stores. To do that I decided to I add flavors like this:
productFlavors {
gms {
dimension "services"
buildConfigField "String", "SERVICE_USED", '"g"'
}
hms {
dimension "services"
buildConfigField "String", "SERVICE_USED", '"h"'
}
}
gmsImplementation 'com.google.firebase:firebase-analytics:17.2.0'
gmsImplementation 'com.google.firebase:firebase-messaging:20.0.0'
gmsImplementation 'com.google.firebase:firebase-ads:18.2.0'
gmsImplementation 'com.google.firebase:firebase-crashlytics:17.2.2'
hmsImplementation 'com.huawei.hms:ads-installreferrer:3.4.34.301'
hmsImplementation 'com.huawei.hms:ads-identifier:3.4.34.301'
hmsImplementation 'com.huawei.hms:hianalytics:5.0.5.301'
hmsImplementation 'com.huawei.hms:iap:5.0.4.301'
hmsImplementation 'com.huawei.hms:push:5.0.4.302'
Now I have a question:
Please correct me if I am wrong, I need to use an abstraction layer for common services right? For example, If I need to use IAP, I need a wrapper class that decides to use GMS or HMS which depends on the device type. If I go with this way I need something like that:
Need an interface that needs to be implemented on HmsIAP and GmsIAP classes for the common methods like requestProduct method, purchaseMethod. etc
A parent class that creates these classes and manages which class to use. That will called "AppIAP" class. The logic layer will use that class for IAP operations which will be not depented to the platform.
This approach makes sense to me, there will be one codebase for two platforms. It looks clean and easy to manage in the future. But the problem is I added flavor for the platform dependencies. So If I try to build hms variant of my code, it won't compile because Gms libraries will be missing. And I still has a GmsIAP class that needs to be build despite I am on the Hms variant.
To resolve that I could try to not use the flavors, with this approach I need to package my app with both platform's libraries, and my app will compile fine. But as looks like in the below link Google play will reject my app due to Hms libraries.
Is Huawei HMS tolerated on Google Play Store?
How can I resolve that?