OSMdroid - error: no suitable constructor found for Overlay(no arguments) constructor Overlay.Overlay(Context) is not applicable
Asked Answered
I

1

6

While extending OSMdroid Overlay class in an application

import org.osmdroid.views.overlay.Overlay;
...
public class MapOverlayArea extends Overlay implements TextToSpeech.OnInitListener, OnTouchListener  {

...

I receive an error:

error: no suitable constructor found for Overlay(no arguments) constructor Overlay.Overlay(Context) is not applicable

Irwinirwinn answered 21/4, 2016 at 16:51 Comment(7)
what version of osmdroid are you based off of?Checkerbloom
did you provide the constructor it's looking for?Checkerbloom
as highlighted by spy: provide the source code of your constructor. It should start with: super(context);Contrapuntist
@Checkerbloom : osmdroid 4.3. NO, i do not know HOW to provide said constructor.Irwinirwinn
@Contrapuntist will include and test. get back 2 u asapIrwinirwinn
Your code would have the same error regardless of the IDE. I've removed references to Android StudioLodestone
@tonygil Please consider answering your own question and approve it instead of doing an edit to the question, this helps filter unanswered question.Asthenia
T
10

As indicated by the error message, the required constructor was missing.

public class MapOverlayArea extends Overlay implements TextToSpeech.OnInitListener, OnTouchListener  {

    public MapOverlayArea(Context ctx) {
        super(ctx);
    }

    //....
}

Including the constructor as above, and calling it correctly from main activity using

MapOverlayArea mapOverlayArea = new MapOverlayArea(context);

solves the problem.

Tartuffery answered 21/4, 2016 at 16:51 Comment(1)
This post was discussed on meta meta.#323904Vehement

© 2022 - 2024 — McMap. All rights reserved.