2014-12-17 5 views
12

Seguo Google Maps Android "iniziare" tutorial- https://developers.google.com/maps/documentation/android/Impossibile risolvere simbolo Problema 'OnMapReadyCallback'

Ma mi sono imbattuto in un errore "" Impossibile risolvere il simbolo 'OnMapReadyCallback', che potrebbe essere una correzione facile, ma mi sta sconcertando Questo è il codice che ho per le mie dichiarazioni di importazione per l'applicazione:

import android.app.Activity; 
import android.support.v4.app.FragmentActivity; 
import android.app.FragmentManager; 
import android.app.FragmentTransaction; 
import android.os.Bundle; 
import android.support.v4.app.ActionBarDrawerToggle; 
import android.support.v4.widget.DrawerLayout; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.AdapterView.OnItemClickListener; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 

public class main extends FragmentActivity implements OnMapReadyCallback { 


    // Within which the entire activity is enclosed 
    DrawerLayout mDrawerLayout; 

    // ListView represents Navigation Drawer 
    ListView mDrawerList; 

    // ActionBarDrawerToggle indicates the presence of Navigation Drawer in the action bar 
    ActionBarDrawerToggle mDrawerToggle; 

    // Title of the action bar 
    String mTitle=""; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

Android Manifest:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="temp.com.temp" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="14" 
     android:targetSdkVersion="19" /> 
    <uses-permission android:name="android.permission.INTERNET"/> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 




     <activity android:name="temp.com.temp.Login" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".main" 
      android:label="@string/app_name" > 
     </activity> 

     <activity 
      android:name="temp.com.temp.Register" 
      android:label="@string/app_name" > 
     </activity> 

     <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 
     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="AIzaSyBCCBIgQMw3XgIK4eQHndGHHlzvcT7vgwQ"/> 
    </application> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <!-- The following two permissions are not required to use 
     Google Maps Android API v2, but are recommended. --> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true"/> 
</manifest> 

layout principale File:

<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<!-- The main content view --> 
<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 
<!-- Google Maps --> 
    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:name="com.google.android.gms.maps.MapFragment"/> 
<!-- The navigation drawer --> 
<ListView android:id="@+id/drawer_list" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="0dp" 
    android:background="#111"/> 
</android.support.v4.widget.DrawerLayout> 
+3

Forse stai introducendo una versione precedente di Maps V2. Se utilizzi Android Studio, prova a "compilare" com.google.android.gms: play-services-maps: 6.5.87'' nella chiusura 'dipendenze'. – CommonsWare

+0

Perfetto! Ha funzionato, grazie mille. – LoneProgrammingWolf

risposta

42

OnMapReadyCallback appena uscito in un recente aggiornamento all'SDK di Maps V2. Se lo desideri, devi eseguire l'aggiornamento a una versione abbastanza nuova di tale SDK.

Gli utenti di Android Studio possono passare a compile 'com.google.android.gms:play-services-maps:6.5.87', da the new Play Services granular dependencies, per ottenere questa nuova classe e possibilmente ridurre le dimensioni del loro APK come vantaggio collaterale.

+0

Gradle mi restituisce "impossibile trovare: com.google.android.gms: play-services-maps: 6.5.87'. Come posso risolvere questo? – udiboy1209

+0

@ udiboy1209: assicurati di aver installato l'ultimo Google Repository tramite l'SDK Manager. – CommonsWare

+0

Sì, ho trovato quella correzione altrove: P. Grazie comunque per il tuo aiuto! – udiboy1209