I am trying to add a map to my android application.
But I am getting the error posted below.
I have installed the google play services, and have also added
the required dependency for my app to support map.
I have added the required api key to the manifest,
added the following line after the application tag
uses-library android:required="true"
android:name="com.google.android.gms"
(the following in an element of the application tag and not an attribute)
An idea what I am doing wrong?
03-12 15:31:11.457: E/AndroidRuntime(12833): FATAL EXCEPTION: main
03-12 15:31:11.457: E/AndroidRuntime(12833): java.lang.ExceptionInInitializerError
03-12 15:31:11.457: E/AndroidRuntime(12833): at java.lang.Class.newInstanceImpl(Native Method)
03-12 15:31:11.457: E/AndroidRuntime(12833): at java.lang.Class.newInstance(Class.java:1319)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.os.Looper.loop(Looper.java:137)
03-12 15:31:11.457: E/AndroidRuntime(12833): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-12 15:31:11.457: E/AndroidRuntime(12833): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 15:31:11.457: E/AndroidRuntime(12833): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 15:31:11.457: E/AndroidRuntime(12833): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-12 15:31:11.457: E/AndroidRuntime(12833): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-12 15:31:11.457: E/AndroidRuntime(12833): at dalvik.system.NativeStart.main(Native Method)
03-12 15:31:11.457: E/AndroidRuntime(12833): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.maps.model.LatLng
so I cracked this question a few days ago and here is how I made it work. I removed all traces of the google play library in the projects sections. Next I re-imported the google play library but this time I clicked the option for copying it into my workspace as well. Next in the added this library in the compile paths and it worked.
来源:https://stackoverflow.com/questions/15370641/google-maps-api-on-android-not-working