krzk
krzk

Reputation: 431

cannot implement OnMapReadyCallback

I'm working on a project with Navigation Drawer, and one of the fragments should be with Google Map.

I'm trying to implement a OnMapReadyCallback interface but it doesn't resolve that symbol.

I have already tried to update Google Play services. Here's my build.gradle :app

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.zakrzewskibartlomiej.cv_v3"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.google.android.gms:play-services:9.0.1'
    compile 'com.google.android.gms:play-services-maps:8.4.0'


}

And here I'm trying to implement this

import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;

public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener, onMapReadyCallback {

    NavigationView navigationView = null;
    Toolbar toolbar = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        //set the fragment initially
        MainFragment fragment = new MainFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container, fragment);
        fragmentTransaction.commit();

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
    }

How can I fix this?

Upvotes: 0

Views: 5377

Answers (2)

OneCricketeer
OneCricketeer

Reputation: 191701

Typo... You have imported this.

import com.google.android.gms.maps.OnMapReadyCallback;

So this needs to be capitalized

onMapReadyCallback

Also, make sure you have the same version of play services if you are going to be using multiple of them (though you seem to only need maps)

compile 'com.google.android.gms:play-services-maps:9.0.1'

Upvotes: 4

Raghavendra
Raghavendra

Reputation: 2303

Try this

Add this in your dependency List

compile 'com.google.android.gms:play-services-maps:8.4.0'

and re-sync and run

Upvotes: 1

Related Questions