0

I would like to display google map in Android wear device using Google Maps Android API v2.

I can access to google play service and get the available status. However, I got NullPointerException error after the code mGoogleMap = fragment.getMap();

// Getting Google Play availability status

    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available

        ....

    }else { // Google Play Services are available

        // Getting reference to the SupportMapFragment
        SupportMapFragment fragment = ( SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

        // Getting Google Map
        mGoogleMap = fragment.getMap();}

My layout file is as follows:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity" >
<fragment
    android:id="@+id/map"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    class="com.google.android.gms.maps.SupportMapFragment" />

Gang Lee
  • 31
  • 3
  • 1
    check this out: http://stackoverflow.com/a/19219547/1428624 might be the issue. – hypd09 Aug 22 '14 at 03:32
  • Thanks. I tried this solution. This solution indeed can solve NullPointerException problem. However, I got another error as follows. My feeling is that maybe my layout file has some problem. Maybe the map layout that can be used in smartphone can not be used in smartwatch. `java.lang.IllegalStateException: Unable to find dynamic class com.google.android.gms.maps.internal.CreatorImpl` – Gang Lee Aug 23 '14 at 08:31
  • Seems unrelated to your question, try cleaning project. Also try posting the full logcat with code as a different question. – hypd09 Aug 23 '14 at 18:56
  • Same error @GangLee, did you find out how to include maps into wear? – IvanSF Dec 22 '14 at 17:04

0 Answers0