Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Duvida no curso Mapas

Olá pessoal, não estou conseguindo abrir o mapa no meu aparelho. segue a minha codificação:

AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <permission
        android:name="br.com.caelum.cadastro.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="SEU_PACOTE.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <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" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="my code" />

        <activity android:name=".Formulario" >
        </activity>
        <activity
            android:name=".ListaAlunos"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name=".SMSReceiver"
            android:enabled="true" >
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".Provas"
            android:label="@string/title_activity_provas" >
        </activity>
        <activity
            android:name=".MostraAlunosProximos"
            android:label="@string/mapas" >
        </activity>       

    </application>

</manifest>

MapaFragment.java

public class MapaFragment extends SupportMapFragment { 

}

map_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <FrameLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/mapa"   
        android:name="com.google.android.gms.maps.SupportMapFragment"     
        />        

</LinearLayout>

MostraAlunosProximos.java

public class MostraAlunosProximos extends FragmentActivity{

    @Override
    protected void onCreate(Bundle arg0) {

        setContentView(R.layout.map_layout);

        try{


        MapaFragment mapaFragment = new MapaFragment();


        FragmentManager  manager = getSupportFragmentManager();

        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(R.id.mapa, mapaFragment);        
        transaction.commit();
        }catch(Exception e )
        {
            Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
        }


    }

}

chamada da activity no método = onOptionsItemSelected da classe ListaAlunos:

@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int itemClicado = item.getItemId();

        case R.id.mapa:            
            Intent irParaMapa = new Intent(this,MostraAlunosProximos.class);
            startActivity(irParaMapa);        

            break;
        default:        
        }

        return super.onOptionsItemSelected(item);
    }
}

Error no console:

09-07 20:12:13.466: E/AndroidRuntime(13983): FATAL EXCEPTION: main 09-07 20:12:13.466: E/AndroidRuntime(13983): Process: br.com.caelum.cadastro, PID: 13983 09-07 20:12:13.466: E/AndroidRuntime(13983): android.util.SuperNotCalledException: Activity {br.com.caelum.cadastro/br.com.caelum.cadastro.MostraAlunosProximos} did not call through to super.onCreate() 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.access$800(ActivityThread.java:135) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.os.Handler.dispatchMessage(Handler.java:102) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.os.Looper.loop(Looper.java:136) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.main(ActivityThread.java:5001) 09-07 20:12:13.466: E/AndroidRuntime(13983): at java.lang.reflect.Method.invokeNative(Native Method) 09-07 20:12:13.466: E/AndroidRuntime(13983): at java.lang.reflect.Method.invoke(Method.java:515) 09-07 20:12:13.466: E/AndroidRuntime(13983): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 09-07 20:12:13.466: E/AndroidRuntime(13983): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 09-07 20:12:13.466: E/AndroidRuntime(13983): at dalvik.system.NativeStart.main(Native Method)

2 respostas

Encontrei um erro na chamada do "super" da classe MostraAlunosProximos.java básico:

mas ainda sim apareceu um novo erro apontando para o meta-data:

AndroidManifest.xml

  <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSy...." />

Novo erro:

09-07 23:50:14.610: E/AndroidRuntime(865): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.caelum.cadastro/br.com.caelum.cadastro.MostraAlunosProximos}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 5089000 but found 0. You must have the following declaration within the element: 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.ActivityThread.access$600(ActivityThread.java:141) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.os.Handler.dispatchMessage(Handler.java:99) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.os.Looper.loop(Looper.java:137) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.ActivityThread.main(ActivityThread.java:5041) 09-07 23:50:14.610: E/AndroidRuntime(865): at java.lang.reflect.Method.invokeNative(Native Method) 09-07 23:50:14.610: E/AndroidRuntime(865): at java.lang.reflect.Method.invoke(Method.java:511) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 09-07 23:50:14.610: E/AndroidRuntime(865): at dalvik.system.NativeStart.main(Native Method) 09-07 23:50:14.610: E/AndroidRuntime(865): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 5089000 but found 0. You must have the following declaration within the element: 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.common.GooglePlayServicesUtil.A(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.maps.internal.u.I(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.maps.internal.u.H(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.maps.SupportMapFragment$b.jz(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.dynamic.a.a(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.dynamic.a.onCreate(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at com.google.android.gms.maps.SupportMapFragment.onCreate(Unknown Source) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.support.v4.app.Fragment.performCreate(Fragment.java:1481) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:908) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1121) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1484) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:571) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.Activity.performStart(Activity.java:5114) 09-07 23:50:14.610: E/AndroidRuntime(865): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153) 09-07 23:50:14.610: E/AndroidRuntime(865): ... 11 more

Alguem pode me ajudar????? registrei corretamente o meu codigo no google Developers Console...

solução!

Consegui resolver... vai ae a resposta pra quem tiver com o mesmo problema..

Acrescentar no AndroidManifest.xml

 <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />