I have an app with the usual Google ad and in-app-payment stuff. It's accepted into the Play Store all right. Now I'd like to make it support both GMS and HMS at the same time (based on the availability of the appropriate services, the app can decide which platform to use). The app, with the Huawei functionality built in, works just fine while testing on my own devices.
However, as soon as Huawei's libraries are bundled with the app, the Play Store Console simply refuses it. No error message, just a red exclamation point. There's no doubt about the situation, I started to remove the Huawei-related parts one by one and as soon as the last bit was removed, the bundle was automagically accepted again.
Yes, sure, I might have made some error I'm not aware of but the situation is, well, rather suspicious. If it makes any difference, I use Flutter and I try to upload an app bundle, not APKs, as per normal these days. The HMS library that seems to make it or break it is com.huawei.hms:hwid:4.0.0.300
from the maven repo at https://developer.huawei.com/repo/
.
So, am I just seeing things or not?
Update:
OK, the quest goes on.
This is quite recent news: https://support.google.com/googleplay/android-developer/answer/9934569
Any existing app that is currently using an alternative billing system will need to remove it to comply with this update. For those apps, we are offering an extended grace period until September 30, 2021 to make any required changes. New apps submitted after January 20, 2021 will need to be in compliance.
No matter what the policy says, the Play Console seems to enforce it already. And as I found by looking into the app bundle, the flavor approach is just not enough. Even with the other flavor, there will remain some packages referenced by Flutter. Maybe just the referenced names, not the actual code after tree shaking, but this is already enough for the refusal.
So, at the end of the day, I really think this question needs to be sorted out and some clear guidelines found for and by ourselves, developers, if we really want to write cross-ecosystem, single source Flutter apps. As for me, I sure want to do it.
I have finally found a kind of a workaround, not automatic, but a useable approach.
Create two subpackages inside your project. They look like normal Flutter packages but reside inside your app. Basically, create two folders,
gms_support
andhms_support
beside your usuallib
. Both are packages with the usual structure:Put all your vendor-dependent stuff into identically structured files inside the respective
lib\src
folders and make sure bothXXX_support.dart
files export them the usual way. The implementations should use the same classes and same signatures. Eachpubspec.yaml
refers to its own, vendor-specific Flutter plugins required for their implementation.Your main app
pubspec.yaml
contains both references:Also, add another
support.dart
inside your main app:Wherever you need vendor-specific behavior in your app, you import and use this
support.dart
file.Then, when you have to change from one flavor to another, you always have to change three things in sync:
support.dart
pubspec.yaml
and make a pub update