I am not able to figure out the error :NoClassDefFoundError . I am trying to create a simple Google map. Is there any problem with the Google play services library?

error:- 

```
 03-28 03:17:45.489: E/AndroidRuntime(2338): FATAL EXCEPTION: main
    03-28 03:17:45.489: E/AndroidRuntime(2338): Process: com.example.gpsdemo, PID: 2338
    03-28 03:17:45.489: E/AndroidRuntime(2338): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.Activity.onCreateView(Activity.java:4785)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.Activity.setContentView(Activity.java:1929)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at com.example.gpsdemo.MainActivity.onCreate(MainActivity.java:12)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.Activity.performCreate(Activity.java:5231)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.os.Handler.dispatchMessage(Handler.java:102)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.os.Looper.loop(Looper.java:136)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at android.app.ActivityThread.main(ActivityThread.java:5017)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at java.lang.reflect.Method.invokeNative(Native Method)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at java.lang.reflect.Method.invoke(Method.java:515)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    03-28 03:17:45.489: E/AndroidRuntime(2338):     at dalvik.system.NativeStart.main(Native Method)

```

MainActivity.java

```
package com.example.gpsdemo;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

```

actvity\_main.xml:

```
<?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"
          android:name="com.google.android.gms.maps.MapFragment"/>

```

Error after changes:-

```
03-28 03:45:52.759: E/AndroidRuntime(2625): FATAL EXCEPTION: main
03-28 03:45:52.759: E/AndroidRuntime(2625): Process: com.example.gpsdemo, PID: 2625
03-28 03:45:52.759: E/AndroidRuntime(2625): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gpsdemo/com.example.gpsdemo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.os.Looper.loop(Looper.java:136)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.ActivityThread.main(ActivityThread.java:5017)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at java.lang.reflect.Method.invoke(Method.java:515)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at dalvik.system.NativeStart.main(Native Method)
03-28 03:45:52.759: E/AndroidRuntime(2625): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.Activity.setContentView(Activity.java:1929)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at com.example.gpsdemo.MainActivity.onCreate(MainActivity.java:26)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.Activity.performCreate(Activity.java:5231)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-28 03:45:52.759: E/AndroidRuntime(2625):     ... 11 more
03-28 03:45:52.759: E/AndroidRuntime(2625): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.Fragment.instantiate(Fragment.java:597)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.Fragment.instantiate(Fragment.java:561)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.Activity.onCreateView(Activity.java:4778)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
03-28 03:45:52.759: E/AndroidRuntime(2625):     ... 20 more
03-28 03:45:52.759: E/AndroidRuntime(2625): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/com.example.gpsdemo-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.gpsdemo-2, /system/lib]]
03-28 03:45:52.759: E/AndroidRuntime(2625):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-28 03:45:52.759: E/AndroidRuntime(2625):     at android.app.Fragment.instantiate(Fragment.java:583)
03-28 03:45:52.759: E/AndroidRuntime(2625):     ... 23 more

```

Here is the manifest file:-

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

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

     <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"/>
     <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" >
         <activity
            android:name="com.example.gpsdemo.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>

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

    </application>

</manifest>

```
['https://Stackoverflow.com/questions/22706628', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3467204/']
This is [documented](http://docs.python.org/2/library/itertools.html#itertools.groupby):

> 
> The returned group is itself an iterator that shares the underlying iterable with `groupby()`. Because the source is shared, when the `groupby()` object is advanced, the previous group is no longer visible.
> 
> 
> 

When you do `list(groupby(...))`, you advance the groupby object all the way to the end, this losing all groups except the last. If you need to save the groups, do as shown in the documentation and save each one while iterating over the groupby object.
The example in the documentation is not as nice as: 

```
list((key, list(group)) for key, group in itertools.groupby(...))

```

in turning the iterator into a list of tuples of keys and lists of groups: `[(key,[group])]` if that is what is desired.