Search code examples
androidgoogle-mapsgoogle-apisamsung-mobile

Android Google Maps Api V2 crashes


i'm trying to make an Android App using Google Maps Api, for that I followed the same step (exact) made by the famous (Ravi Tamada ) is his tutorial:

Link to the tutorial: http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/

but when I try to compile the project an run it on my Android device (Samsung Galaxy S3, Android Version: 4.1.2) it crashes and gives me the following error msg in the LogCast!

Link to My LogCast: http://openensak.com/img/LogCast.png

i don't know what's wrong !!!


Solution

  • use

    import android.support.v4.app.Fragment;
    YourActivity extends FragmentActivity 
    

    instead of

    import android.app.Fragment;
    YourActivity extends Activity 
    

    and Please add the API KEY in your manifest file

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

    is in the element of AndroidManifest.xml