I\'m trying my hand and Android Application Development. I\'m currently using Eclipse (I can\'t remember the version, whatever the newest is). I\'ve crossed a bridge where I
Try to add google-play-services library reference to your project. If you are using Eclipse, you need to go to Project->Properties->Android
and Add
google-play-services library project.
ALTERNATIVELY,
You can modify project.properties
file manually.
Try to add reference to your google_play_services library. So my project.properties
file looks like:
# Project target.
target=android-17
android.library.reference.1=../../../android-sdks/extras/google/google_play_services/libproject/google-play-services_lib
In your case path to google-play-services lib may be different
I tried to import your code and it crashed as well. When I modified properties file - I've got map running
I had the same problem, solved it by modifying the Manifest. This is my manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.gps"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="example.gps.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<!-- End of copy. -->
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<YOUR VALUE>"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="example.gps.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>
And the xml file is
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
/>
The java class is
public class MainActivity extends FragmentActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
That solved my problem
I had the same problem and I did the mistake to only add one of the 2 following tags.
The actual error is really misleading, as you might be thinking of some API level UI issue.
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="<YOUR VALUE>"/> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Note that you are also missing one of these two