airbnb / AirMapView

A view abstraction to provide a map user interface with various underlying map providers
http://airbnb.github.io/AirMapView/
Apache License 2.0
1.87k stars 215 forks source link

java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up. #83

Open Piero87 opened 8 years ago

Piero87 commented 8 years ago

Hi, i have tried to create a sample with this code:

import com.airbnb.android.airmapview.AirMapMarker;
import com.airbnb.android.airmapview.AirMapPolyline;
import com.airbnb.android.airmapview.AirMapView;
import com.airbnb.android.airmapview.DefaultAirMapViewBuilder;
import com.airbnb.android.airmapview.listeners.OnMapInitializedListener;
import com.google.android.gms.maps.model.LatLng;

import java.util.Arrays;

public class SelectMapAreaGame extends AppCompatActivity implements OnMapInitializedListener {

    private AirMapView map;
    private DefaultAirMapViewBuilder mapViewBuilder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_map_area_game);

        mapViewBuilder = new DefaultAirMapViewBuilder(this);
        map = (AirMapView) findViewById(R.id.map_view);

        map.setOnMapInitializedListener(this);
        map.initialize(getSupportFragmentManager());

    }

    private void addMarker(String title, LatLng latLng, int id) {
        map.addMarker(new AirMapMarker.Builder()
                .id(id)
                .position(latLng)
                .title(title)
                .iconId(R.drawable.ghost)
                .build());
    }

    @Override public void onMapInitialized() {
        System.out.println("Map onMapInitialized triggered");
        final LatLng airbnbLatLng = new LatLng(37.771883, -122.405224);
        addMarker("Airbnb HQ", airbnbLatLng, 1);
        addMarker("Performance Bikes", new LatLng(37.773975, -122.40205), 2);
        addMarker("REI", new LatLng(37.772127, -122.404411), 3);
        addMarker("Mapbox", new LatLng(37.77572, -122.41354), 4);
        map.animateCenterZoom(airbnbLatLng, 10);

        // Add Polylines
        LatLng[] latLngs = {
                new LatLng(37.77977, -122.38937),
                new LatLng(37.77811, -122.39160),
                new LatLng(37.77787, -122.38864)};

        map.addPolyline(new AirMapPolyline(Arrays.asList(latLngs), 5));

        // Add Circle
        map.drawCircle(new LatLng(37.78443, -122.40805), 1000);

        // enable my location
        map.setMyLocationEnabled(true);
    }
}

and i have a blank view with this in the console:

W/webcore: java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
                                                                          at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1684)
                                                                          at android.webkit.WebViewCore$EventHub.access$7900(WebViewCore.java:927)
                                                                          at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1796)
                                                                          at android.webkit.WebView.sendOurVisibleRect(WebView.java:2953)
                                                                          at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:593)
                                                                          at android.webkit.ZoomManager.access$1700(ZoomManager.java:49)
                                                                          at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:984)
                                                                          at android.os.Handler.handleCallback(Handler.java:605)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                          at android.os.Looper.loop(Looper.java:137)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:4424)
                                                                          at java.lang.reflect.Method.invokeNative(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:511)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
                                                                          at dalvik.system.NativeStart.main(Native Method)

how i can fix?

felipecsl commented 8 years ago

That exception is coming from the webcore process, not your process. What device model and Android version are you running on?

Piero87 commented 8 years ago

I am using an Android emulator api level 15.

Il giorno 05 mar 2016, alle ore 00:08, Felipe Lima notifications@github.com ha scritto:

That exception is coming from the webcore process, not your process. What device model and Android version are you running on?

— Reply to this email directly or view it on GitHub.

felipecsl commented 8 years ago

I don't have a device with API 15 available for testing, but I tried on one with API 16 and it worked fine. Can you try on a different device to see if the problem persists?

Piero87 commented 8 years ago

At the momento i can try only on the emulator, and my target is for a device with API Level 15

Il giorno 05 mar 2016, alle ore 00:39, Felipe Lima notifications@github.com ha scritto:

I don't have a device with API 15 available for testing, but I tried on one with API 16 and it worked fine. Can you try on a different device to see if the problem persists?

— Reply to this email directly or view it on GitHub https://github.com/airbnb/AirMapView/issues/83#issuecomment-192525470.