20

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.

Melody Horn
  • 778
  • 2
  • 6
  • 22

5 Answers5

50

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.

Timo
  • 3,335
  • 30
  • 25
  • @Jackie, sorry I can't help you there. At first glance it seems you may need to find a way to link the virtual machine to an actual Google account, but honestly I have no idea.. So why don't you Google up: genymotion maps NoClassDefFoundError and figure it out, post an answer up here and on the numerous SO questions concerning this specific issue and reap the fame. Or at least go vote up all of those questions :) – Timo Dec 27 '13 at 22:28
  • 1
    Thanks @Timo, I solved the problem. Just by installing google maps from PlayStore. I guess device must has google maps to use Map v2 – Jackie Dec 29 '13 at 14:58
12

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 ...
Matroska
  • 6,885
  • 14
  • 63
  • 99
2

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

user1616685
  • 1,310
  • 1
  • 15
  • 36
1

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.

Sharjeel
  • 15,588
  • 14
  • 58
  • 89
1

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.

Hema
  • 511
  • 4
  • 11