Description
After upgrading huawei_map from 6.11.2 to 6.12.0+301, all markers using a custom
icon created with BitmapDescriptor.fromAssetImage(...) (or fromAsset) are no
longer displayed on the map. Markers with the default icon work fine.
Root cause
In 6.12.0+301 the deprecated io.flutter.view.FlutterMain was removed from
android/src/main/java/com/huawei/hms/flutter/map/utils/Convert.java
(toBitmapDescriptor), but the replacement passes the raw Flutter asset path to
BitmapDescriptorFactory.fromAsset(...):
case Param.FROM_ASSET_IMAGE:
if (data.size() == 3) {
return BitmapDescriptorFactory.fromAsset(
Convert.toString(data.get(1)).replaceFirst("^/", ""));
}
Flutter assets live inside the APK under flutter_assets/, so the lookup for
e.g. assets/img/pin.png fails (it should be flutter_assets/assets/img/pin.png)
and the marker is silently not rendered.
In 6.11.2 this worked because FlutterMain.getLookupKeyForAsset() added the
flutter_assets/ prefix.
Fix
Replace the removed FlutterMain call with the v2-embedding equivalent instead
of the raw path:
import io.flutter.FlutterInjector;
...
return BitmapDescriptorFactory.fromAsset(
FlutterInjector.instance().flutterLoader().getLookupKeyForAsset(Convert.toString(data.get(1))));
(same change for the three call sites in FROM_ASSET / FROM_ASSET_IMAGE).
I verified this fix on a device: fleoparra@3a8a10b
Environment
- huawei_map: 6.12.0+301 (pub.dev)
- Flutter: Flutter 3.41.9
- Device: ALL Huawei devices with HMS
Description
After upgrading huawei_map from 6.11.2 to 6.12.0+301, all markers using a custom
icon created with
BitmapDescriptor.fromAssetImage(...)(orfromAsset) are nolonger displayed on the map. Markers with the default icon work fine.
Root cause
In 6.12.0+301 the deprecated
io.flutter.view.FlutterMainwas removed fromandroid/src/main/java/com/huawei/hms/flutter/map/utils/Convert.java(
toBitmapDescriptor), but the replacement passes the raw Flutter asset path toBitmapDescriptorFactory.fromAsset(...):Flutter assets live inside the APK under
flutter_assets/, so the lookup fore.g.
assets/img/pin.pngfails (it should beflutter_assets/assets/img/pin.png)and the marker is silently not rendered.
In 6.11.2 this worked because
FlutterMain.getLookupKeyForAsset()added theflutter_assets/prefix.Fix
Replace the removed
FlutterMaincall with the v2-embedding equivalent insteadof the raw path:
(same change for the three call sites in
FROM_ASSET/FROM_ASSET_IMAGE).I verified this fix on a device: fleoparra@3a8a10b
Environment