Oh Danny Boy
Oh Danny Boy

Reputation: 4887

NoClassDefFoundError Google-Play-Services / Maps

Getting NoClassDefFoundError within project and in Google Maps for Android sample found in google-play-services folder.

I have tried so far:

Any ideas?

Manifest:

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

    <uses-sdk
        android:minSdkVersion="18"
        android:targetSdkVersion="21" />

    <permission
        android:name="com.package.projectname.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.package.projectname.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.package.projectname.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=".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>
        <activity
            android:name="com.package.projectname.MapActivity"
            android:label="@string/title_activity_map"
            android:parentActivityName="com.package.projectname.MainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.package.projectname.MainActivity" />
        </activity>

        <uses-library
            android:name="com.google.android.maps"
            android:required="true" />

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

</manifest>

Upvotes: 3

Views: 1036

Answers (1)

brokethebuildagain
brokethebuildagain

Reputation: 2191

I don't think you need the line:

    <uses-library
        android:name="com.google.android.maps"
        android:required="true" />

In fact, I think that's the name of the old maps library. Try removing it and see if that fixes your problem. Also, make sure your code is importing from com.google.android.gms.maps and com.google.android.gms.maps.model, the packages for Google Maps API V2.

UPDATE

Your build configuration isn't including the Google Play Services jar in your APK.

To fix this in IntelliJ: https://stackoverflow.com/a/17977734/1235702

To fix this in Eclipse, follow steps 3 and 4 here: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw (I didn't write this doc, but kudos to whoever did!)

  1. Add the Google Play Services project into your Eclipse workspace.
    • Click File -> Import..., select Android -> Existing Android Code into Workspace Browse to and select /extras/google/google_play_services/libproject/google-play-services_lib
  2. To add the dependency to Google Play Services into your project
    • Project -> Properties -> Android -> Library, Add -> google-play-services_lib

(Sorry; the markdown won't let me set the numbers to 3 and 4 explicitly.)

Screenshot from OP for posterity: Eclipse properties for Google Play Services Lib

Upvotes: 2

Related Questions