Skip to content

[huawei_map] 6.12.0+301: custom marker icons from fromAssetImage/fromAsset no longer load (missing flutter_assets/ prefix) #443

Description

@fleoparra

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions