Google Maps api v2 class not found
Asked Answered
R

2

7

I am using google maps api v2 and everything was working fine . today morning i updated the sdk and now maps are not working. Tried a lot of things like importing the lib project again and all but nothing seems to work . Plz help.

This is the logcat output

05-16 08:53:34.327: E/dalvikvm(3422): Could not find class  'com.google.android.gms.maps.model.LatLng', referenced from method  com.apptree.de_luxe.InfoActivity.<clinit>
05-16 08:53:34.327: W/dalvikvm(3422): VFY: unable to resolve new-instance 170 (Lcom/google/android/gms/maps/model/LatLng;) in Lcom/apptree/de_luxe/InfoActivity;
05-16 08:53:34.327: D/dalvikvm(3422): VFY: replacing opcode 0x22 at 0x0000
05-16 08:53:34.327: E/dalvikvm(3422): Could not find class 'com.google.android.gms.maps.model.MarkerOptions', referenced from method com.apptree.de_luxe.InfoActivity.setUpMap
05-16 08:53:34.327: W/dalvikvm(3422): VFY: unable to resolve new-instance 172 (Lcom/google/android/gms/maps/model/MarkerOptions;) in Lcom/apptree/de_luxe/InfoActivity;
05-16 08:53:34.327: D/dalvikvm(3422): VFY: replacing opcode 0x22 at 0x0002
05-16 08:53:34.347: E/dalvikvm(3422): Could not find class 'com.google.android.gms.maps.MapFragment', referenced from method com.apptree.de_luxe.InfoActivity.setUpMapIfNeeded
05-16 08:53:34.347: W/dalvikvm(3422): VFY: unable to resolve check-cast 169 (Lcom/google/android/gms/maps/MapFragment;) in Lcom/apptree/de_luxe/InfoActivity;
05-16 08:53:34.357: D/dalvikvm(3422): VFY: replacing opcode 0x1f at 0x000f
05-16 08:53:34.367: D/dalvikvm(3422): DexOpt: unable to opt direct call 0x029b at 0x0c in Lcom/apptree/de_luxe/InfoActivity;.<clinit>
05-16 08:53:34.367: D/dalvikvm(3422): DexOpt: unable to opt direct call 0x029c at 0x04 in Lcom/apptree/de_luxe/InfoActivity;.setUpMap
05-16 08:53:34.387: W/dalvikvm(3422): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/apptree/de_luxe/InfoActivity;
05-16 08:53:34.387: W/dalvikvm(3422): Class init failed in newInstance call (Lcom/apptree/de_luxe/InfoActivity;)
05-16 08:53:34.387: D/AndroidRuntime(3422): Shutting down VM
05-16 08:53:34.398: W/dalvikvm(3422): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
05-16 08:53:34.457: E/AndroidRuntime(3422): FATAL EXCEPTION: main
05-16 08:53:34.457: E/AndroidRuntime(3422): java.lang.ExceptionInInitializerError
05-16 08:53:34.457: E/AndroidRuntime(3422):     at java.lang.Class.newInstanceImpl(Native Method)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at java.lang.Class.newInstance(Class.java:1319)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.os.Looper.loop(Looper.java:137)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at android.app.ActivityThread.main(ActivityThread.java:5041)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at java.lang.reflect.Method.invokeNative(Native Method)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at java.lang.reflect.Method.invoke(Method.java:511)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-16 08:53:34.457: E/AndroidRuntime(3422):     at dalvik.system.NativeStart.main(Native Method)
05-16 08:53:34.457: E/AndroidRuntime(3422): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.maps.model.LatLng
05-16 08:53:34.457: E/AndroidRuntime(3422):     at com.apptree.de_luxe.InfoActivity.<clinit>(InfoActivity.java:35)
05-16 08:53:34.457: E/AndroidRuntime(3422):     ... 15 more
Reflector answered 16/5, 2013 at 8:59 Comment(6)
have you refered google play services library in your android map project?Stationary
@Reflector Raghunandan is right...you should properly reference google-play-serives_lib to your project.Casern
have done that . In properties under Android i have added the lib project and i am targeting google apiReflector
have you referred the library project as below?Stationary
what key you have used to create your Map key? Is that was your Eclipse default key?Chargeable
no i created a key on google api consoleReflector
E
22

In Eclipse go to:

"Project" -> "Properties" -> "Java Build Properties"

On the "Order and Export" tab I checked "Android Private Libraries" on my project. I also did this for the library project it references. This fixed my class not found errors following upgrading to SDK 22.

Eusebioeusebius answered 16/5, 2013 at 9:2 Comment(4)
+1 i just encountered the same problem after update and solved it.Stationary
also, you need Android SDK Build tools for ADT 22.Dashed
I had to do this for all my library projects. What an intense twenty minutes though lolBenighted
I also had to change the order. I moved the "android private libraries" down, so that they were below the actual libraries, but above "android dependencies". With this additional step it worked.Jochbed
S
4

You should refer the google play services library project in your map project.

Import your library project to your worksace. import the same to eclipse.

Right click on your project. goto properties. Choose android. click android. browse and add the library project.

enter image description here

Stationary answered 16/5, 2013 at 9:14 Comment(7)
have you deleted old one from your current workspace before importing new lib?Inconvenient
yes i removed everything and one more before today it was working without importing it to my workspace and after updating its not working either wayReflector
you need to import it into your current workspace.then add it to your project as library.I hope it will work.Inconvenient
thanks but the above solution by tafty worked. I dont know why it stopped working after updation.Reflector
@Reflector strange the above is the recommended way of referencing the library project. I need to note this behaviourStationary
ya i know this sucks i have used several library projects and i have refrenced them the same way you told and they always worked but i dont know what changed after updating to sdk 22 .Reflector
How to from Google: Map Fragment / MapView v2 Quick Start docs.google.com/document/…Ovine

© 2022 - 2024 — McMap. All rights reserved.