Melody Horn
Melody Horn

Reputation: 768

Google Maps Android API gives a NoClassDefFoundError

My app just consists of a map with an overlay, but when I create my MapView, my app crashes with a NoClassDefFoundError. I'm using the Google API AVD that matches my target, but apparently I'm still doing something wrong. Any ideas?

EDIT: In case it helps, my NoClassDefFoundError is complaining about [generic]. I can understand why there's no class definiton for [generic], but I'm not sure where that's coming from.

Also, a later ClassNotFoundException complains of com.google.android.maps.MapView in loader dalvik.system.PathClassLoader[/data/app/mathphreak.cellmap-1.apk], and that then goes on to cause a different NoClassDefFoundError for java.lang.NoClassDefFoundError: com.google.android.maps.MapView.

Upvotes: 19

Views: 15250

Answers (5)

Timo
Timo

Reputation: 3404

Make sure you have included the following line in your application manifest:

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

and make sure it's in the correct place. My problem (had similar error messages) was that I had put this in there but like the uses-permission stuff it was just under the root element manifest, when in fact the uses-library element is suppose to be placed under the application element. In case I wasn't clear enough see the part: Configuring the application manifest from Sameers link.

Upvotes: 49

user1616685
user1616685

Reputation: 1340

I had the same problem and I solved it changing in the manifest:

<activity android:name=".GpsActivity" ></activity>

to

<activity android:name="GpsActivity" ></activity>

the "dot" is the difference

Upvotes: 2

Hema
Hema

Reputation: 511

One More thing to check,

  • If you have two sets of libraries for maps. Then it doesnt work. Please check in build path.

Hope, this may work for some one.

Upvotes: 1

Matroska
Matroska

Reputation: 6923

I had the same problem and I fixed it thanks to Timo Lehto answer but putting this string

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

after the opening application tag (at the beginning)

   <application
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <uses-library
            android:name="com.google.android.maps"
            android:required="true" />

        <activity ...

Upvotes: 12

Sharjeel
Sharjeel

Reputation: 15798

There could be two things.

i) Make sure you have defined all of your Activity classes in AndroidManifest.xml class.

ii) Make sure you are compiling your Android project using "Google APIs" instead of "Android 2.x", If you compile using Google APIs only then It will add Google Maps classes.

Upvotes: 1

Related Questions