Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google map API v2 is not working

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
like image 397
xyz Avatar asked Dec 04 '12 12:12

xyz


People also ask

Why is my Google Maps API not working?

There are a several reasons why your google maps may not be working, the most common issue being no Google Map API key set or set incorrectly. To use the Google Maps JavaScript API, you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app.

How do I know if my Google map API key is working?

Open the Credentials page of the Google dashboard. Find your key in the list and click on the name: Check for any restrictions under API Restrictions.


2 Answers

I had the same problem and got resolved by doing the following,

  • Remove the android-support-v4.jar that you added manually
  • Right click on the project and select Android Tools -> Add Support Library ...

After this everything worked for me.

like image 187
Jairo Vazquez Avatar answered Oct 20 '22 04:10

Jairo Vazquez


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.

like image 38
Andrew S Avatar answered Oct 20 '22 04:10

Andrew S