Android crash when displaying a custom marker info window using markerInfoContents

Open Beginner friendly
#680 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
92/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, typescript
Domain
mobile-dev

Research direction

Start in packages/google-maps/index.android.ts at the markerInfoContents handling that adds info.view to a GridLayout. Verify the returned native view is the wrapper container, then reproduce by repeatedly opening markers and confirm custom information windows no longer trigger the already-parented-child crash on Android.

Written by the indexing model from the issue text.

Description

Android crash when displaying a custom marker info window using markerInfoContents

Using markerInfoContents to display a custom NativeScript view causes Android to crash on API 36, API 37, and a physical Android device.

Error

java.lang.IllegalStateException:
The specified child already has a parent.
You must call removeView() on the child's parent first.

Cause

In packages/google-maps/index.android.ts, the plugin adds info.view to a GridLayout container but returns the child:

container.addChild(info.view)
return info.view.nativeView

Because the returned child already belongs to the container, Google Maps attempts to attach an already-parented view.

Suggested fix

Return the wrapper container instead:

return container.nativeView

The custom information-window view should display without crashing when repeatedly opening markers.

Image
Dominant language
TypeScript
Stars
206
Forks
123
Avg merge
2d 1h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NativeScript/plugins

All issues in NativeScript/plugins

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.