Larry Dinh
Larry Dinh

Reputation: 387

Android Google Map API v2 NoClassDefFoundError error

I downloaded google map api v2 sample and followed official tutorial on google website (installed and added google play services) but i got NoClassDefFoundError error when run sample as below

07-26 02:01:04.821: I/Process(620): Sending signal. PID: 620 SIG: 9
07-26 02:01:18.559: W/dalvikvm(682): Unable to resolve superclass of Lcom/example/mapdemo/BasicMapActivity; (80)
07-26 02:01:18.559: W/dalvikvm(682): Link of class 'Lcom/example/mapdemo/BasicMapActivity;' failed
07-26 02:01:18.559: E/dalvikvm(682): Could not find class 'com.example.mapdemo.BasicMapActivity', referenced from method com.example.mapdemo.MainActivity.<clinit>
07-26 02:01:18.559: W/dalvikvm(682): VFY: unable to resolve const-class 128 (Lcom/example/mapdemo/BasicMapActivity;) in Lcom/example/mapdemo/MainActivity;
07-26 02:01:18.559: D/dalvikvm(682): VFY: replacing opcode 0x1c at 0x000d
07-26 02:01:18.658: W/dalvikvm(682): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/example/mapdemo/MainActivity;
07-26 02:01:18.658: W/dalvikvm(682): Class init failed in newInstance call (Lcom/example/mapdemo/MainActivity;)
07-26 02:01:18.676: D/AndroidRuntime(682): Shutting down VM
07-26 02:01:18.676: W/dalvikvm(682): threadid=1: thread exiting with uncaught exception (group=0x40014760)
07-26 02:01:18.791: E/AndroidRuntime(682): FATAL EXCEPTION: main
07-26 02:01:18.791: E/AndroidRuntime(682): java.lang.ExceptionInInitializerError
07-26 02:01:18.791: E/AndroidRuntime(682):  at java.lang.Class.newInstanceImpl(Native Method)
07-26 02:01:18.791: E/AndroidRuntime(682):  at java.lang.Class.newInstance(Class.java:1301)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1663)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.app.ActivityThread.access$1500(ActivityThread.java:122)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.os.Looper.loop(Looper.java:132)
07-26 02:01:18.791: E/AndroidRuntime(682):  at android.app.ActivityThread.main(ActivityThread.java:4025)
07-26 02:01:18.791: E/AndroidRuntime(682):  at java.lang.reflect.Method.invokeNative(Native Method)
07-26 02:01:18.791: E/AndroidRuntime(682):  at java.lang.reflect.Method.invoke(Method.java:491)
07-26 02:01:18.791: E/AndroidRuntime(682):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-26 02:01:18.791: E/AndroidRuntime(682):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-26 02:01:18.791: E/AndroidRuntime(682):  at dalvik.system.NativeStart.main(Native Method)
07-26 02:01:18.791: E/AndroidRuntime(682): Caused by: java.lang.NoClassDefFoundError: com.example.mapdemo.BasicMapActivity
07-26 02:01:18.791: E/AndroidRuntime(682):  at com.example.mapdemo.MainActivity.<clinit>(MainActivity.java:100)
07-26 02:01:18.791: E/AndroidRuntime(682):  ... 15 more
07-26 02:06:18.960: I/Process(682): Sending signal. PID: 682 SIG: 9  

I got google api key by combine SHA 1 fingerprint at "Window > Preferences > Android > Build > SHA 1 fingerprint" with google sample package name "com.example.mapdemo"

Please help me, sorry for my english, thanks very much.


I changed target sdk and emulator is 4.0, that error is disappeared but i got a new is "Google play services is missiong".

Then, i changed target sdk and emulator is 4.2.2, i got error "google play services out of date. requires 3159100 but found 3136130"

Please help me.

Upvotes: 0

Views: 1004

Answers (2)

Yang_2333
Yang_2333

Reputation: 714

Still look at the Properties, instead of switch the positions, try to select all the libs.

I did this and it solves my problem.

enter image description here

Notice: You can run the Map API sample code now, but the Google Map app in emulator still shows nothing. If you want to run this app, you need to install Google Play Service app first.

Upvotes: 0

Tarsem Singh
Tarsem Singh

Reputation: 14199

  1. Go to "Properties" of the project.
  2. Select "Java Build Path"
  3. Select "Order and Export" Tab
  4. You should see the selected project's "src" and "gen" paths and dependencies here.
  5. The order how they listed were first "src" and then "gen" path
  6. I switch them, so that "gen" folder is build before the "src"

reference https://stackoverflow.com/a/12702315/2398886

Upvotes: 1

Related Questions