2

I've seen solutions like:

Have both GMS and HMS in the project

to have both GMS and HMS in java based android apps.

Is it possible to do simillar thing in flutter app? I can set the use of different plugins in build.gradle, but is it possible to have the same named classes with different implementation, like in the example above?

Michael
  • 51
  • 4

2 Answers2

1

Currently, only Java is supported. For other development language, like Flutter, is under analysis and evaluation. It could be supported in a cross-platform IDE in the future release.

Zinna
  • 1,947
  • 2
  • 5
  • 20
  • what do you mean under development? the hms plugin? so its not possible right now? one of the drawbacks with flutter now is there is no support for flavor dependencies which is very important – chitgoks Oct 29 '21 at 12:16
0

Update

The Google Play APK can contain both GMS Ads and HMS Ads without conflicting. Therefore, flavors do not need to be differentiated. You can rename different classes when using, as follows:

import 'package:huawei_ads/hms_ads_lib.dart' as hms_ads;
import 'package:google_mobile_ads/google_mobile_ads.dart' as gms_ads;

hms_ads.BannerAd? _testads;
gms_ads.BannerAd? _testads2;

enter image description here


Currently, the Flutter plug-in of the HMS is available. However, the interfaces in the plug-in are different from those in the GMS. You may need to call the plug-in based on the phone`s environment (G or H).

Overview of Flutter plug-ins Support,see Docs.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • i do not understand. While flavors are not possible out of the box in Flutter, we have no choice but to import both, say gms and hms ad libraries. Now, the problem is in the code. e.g. BannerAd both use the same class name. Conditional imports are not possible if lib exists or not. So what is the solution for this one. – chitgoks Oct 31 '21 at 04:28
  • hi@chitgoks, i just updated my answer, pls kindly refer that. – zhangxaochen Nov 02 '21 at 01:34
  • thank you. yes. sadly flutter does not support dependency flavors right now. – chitgoks Nov 03 '21 at 02:09