-1

I've been trying to follow a tutorial on the link below, so to utilize the Google maps API within an Android application, but I just can't manage to get it to work properly. I have checked out this website and others. I've requested a new API key several times, I've made sure it was requested correctly (SHA1 fingerprint then my project name, which in this case is "com.example.reallystuck"). I've also made sure the code is correct but still it won't work, I just get the error "Unfortunately GoogleMaps V2 has stopped" when loading it up on the android emulator as in the picture below.

If I have got any of the code wrong or done something stupid, I don't mind people pointing it out to me. I just want it to work.

Tutorial I have used.

On open app error screenshot .

Code:

MainActivity.java

package com.example.reallystuck; 
import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.MapFragment; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.Marker; 
import com.google.android.gms.maps.model.MarkerOptions; 
public class MainActivity extends Activity {     
private GoogleMap mMap;         
@Override     
protected void onCreate(Bundle savedInstanceState) {         
super.onCreate(savedInstanceState);         
setContentView(R.layout.activity_main);             
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();         
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);         
final LatLng CIU = new LatLng(35.21843892856462, 33.41662287712097);         
Marker ciu = mMap.addMarker(new MarkerOptions()                                   
.position(CIU).title("My Office"));     
}     
@Override     
public boolean onCreateOptionsMenu(Menu menu) {         
// Inflate the menu; this adds items to the action bar if it is present.         
getMenuInflater().inflate(R.menu.main, menu);         
return true;     } } 

Android Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.reallystuck"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />
        <permission
        android:name="com.example.reallystuck.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"></permission>
    <uses-permission
        android:name="com.example.reallystuck.permission.MAPS_RECEIVE"/>
    <uses-permission
        android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission
        android:name="android.permission.INTERNET"/>
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <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="REMOVED KEY"/>
        <activity
            android:name="com.example.reallystuck.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

activity_main.xml

<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"    
android:paddingBottom="@dimen/activity_vertical_margin"    
android:paddingLeft="@dimen/activity_horizontal_margin"    
android:paddingRight="@dimen/activity_horizontal_margin"    
android:paddingTop="@dimen/activity_vertical_margin"    
tools:context=".MainActivity" >
<TextView        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:text="@string/hello_world" />
<fragment
        android:id="@+id/map"     
        android:layout_width="match_parent"        
        android:layout_height="match_parent"        
class="com.google.android.gms.maps.MapFragment"/>
</RelativeLayout>

Link to logcat file: http://www.mediafire.com/view/1z75u6xmz97bz6z/log.txt

Glorfindel
  • 21,988
  • 13
  • 81
  • 109

1 Answers1

0

The tutorial is not complete. You should add the following lines into < application > element:

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

Please refer to official documentation

user2340612
  • 10,053
  • 4
  • 41
  • 66