I am trying to run sample code mention here : Google Maps Android API V2 Sample code
but i am getting error NoClassDefFound. Below is my logcat.
Can any one help me to solve it. Any help is highly appricated Thanks
12-04 18:04:18.854: E/AndroidRuntime(1801): java.lang.ExceptionInInitializerError
12-04 18:04:18.854: E/AndroidRuntime(1801): at java.lang.Class.newInstanceImpl(Native Method)
12-04 18:04:18.854: E/AndroidRuntime(1801): at java.lang.Class.newInstance(Class.java:1319)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.os.Looper.loop(Looper.java:137)
12-04 18:04:18.854: E/AndroidRuntime(1801): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-04 18:04:18.854: E/AndroidRuntime(1801): at java.lang.reflect.Method.invokeNative(Native Method)
12-04 18:04:18.854: E/AndroidRuntime(1801): at java.lang.reflect.Method.invoke(Method.java:511)
12-04 18:04:18.854: E/AndroidRuntime(1801): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-04 18:04:18.854: E/AndroidRuntime(1801): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-04 18:04:18.854: E/AndroidRuntime(1801): at dalvik.system.NativeStart.main(Native Method)
12-04 18:04:18.854: E/AndroidRuntime(1801): Caused by: java.lang.NoClassDefFoundError: com.example.mapdemo.BasicMapActivity
12-04 18:04:18.854: E/AndroidRuntime(1801): at com.example.mapdemo.MainActivity.<clinit>(MainActivity.java:98)
12-04 18:04:18.854: E/AndroidRuntime(1801): ... 15 more
Multiple reference of android-support-v4.jar
This is worked for me.
If your project and goolge play services library project both contain android-support-v4.jar then it will conflict.
Remove android-support-v4.jar from any one project.
Is the Google Play Services library project referenced as a library project from your Sampleproject?
This worked for me.
Once you have imported the Android-Support-V4.jar and the Google_Play_Services_lib.jar, go to:
Project Properties > Java Build Path > Order and Export.
Then ensure you the check boxes beside Android-Support-V4.jar and the Google_Play_Services_lib.jar are selected.
Click ok, then run. All should be well.
Edit: Jairo's answer worked for me. Edit2: It runs but no map shown. I have the API key in place. It's a new one just got it. Used package name com.example.mapdemo. Edit3: Refreshed API key (they dont last long). Still no map shown. Edit4: Had wrong SHA1 from using wrong keystore. When I searched for it, search did not find it in .android folder (ubuntu not searching hidden folder), instead showed me keystores I got from downloading android source code.
I'm having the exact same error.
MainActivity starts, refers to BasicMapActivity which is in the same package. BasicMapActivity extends FragmentActivity which is in the android-support-v4.jar.
On this page: https://developers.google.com/maps/documentation/android/intro See Step 4: "Select Add External Jars, include the following jar files, and click OK: /extras/android/compatibility/v4/android-support-v4.jar"
My path was to the jar was /support/ instead of /compatibility/ - I don't have a /compatibility/ folder. Maybe that's a clue?
My android-support-v4.jar has a Modified date of Mon 19 Nov 2012 09:14:47 AM EST. Makes me wonder if I am missing the latest update. SDK Manager has been run and rerun.
Depending on how your source is set up, you may need to set the android-support-library to be exported (right click->properties->java build path->order and export) Also, you need to be using SupportMapFragment rather than MapFragment for the support library. Make sure you're also using getSupportFragmentManager rather than getFragmentManager.
I had the same problem and got resolved by doing the following,
After this everything worked for me.