Configuring google maps in Android app

2019-08-26 03:00发布

问题:

I am trying to configure google maps API v2 in my app. For some reason, I am not able to configure it. I followed all the instruction step by step and the manifest file is as per the requirement. When I try to launch google maps, I see a blank screem

The exception is below

11-14 05:19:51.948: E/Parcel(850): Class not found when unmarshalling: com.google.android.gms.maps.model.LatLng
11-14 05:19:51.948: E/Parcel(850): java.lang.ClassNotFoundException: com.google.android.gms.maps.model.LatLng
11-14 05:19:51.948: E/Parcel(850):  at java.lang.Class.classForName(Native Method)
11-14 05:19:51.948: E/Parcel(850):  at java.lang.Class.forName(Class.java:251)
11-14 05:19:51.948: E/Parcel(850):  at java.lang.Class.forName(Class.java:216)
11-14 05:19:51.948: E/Parcel(850):  at android.os.Parcel.readParcelableCreator(Parcel.java:2133)
11-14 05:19:51.948: E/Parcel(850):  at android.os.Parcel.readParcelable(Parcel.java:2097)
11-14 05:19:51.948: E/Parcel(850):  at android.os.Parcel.readValue(Parcel.java:2013)
11-14 05:19:51.948: E/Parcel(850):  at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
11-14 05:19:51.948: E/Parcel(850):  at android.os.Bundle.unparcel(Bundle.java:249)
11-14 05:19:51.948: E/Parcel(850):  at android.os.Bundle.getString(Bundle.java:1118)
11-14 05:19:51.948: E/Parcel(850):  at android.content.Intent.getStringExtra(Intent.java:5128)
11-14 05:19:51.948: E/Parcel(850):  at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1453)
11-14 05:19:51.948: E/Parcel(850):  at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1052 )
11-14 05:19:51.948: E/Parcel(850):  at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4183)
11-14 05:19:51.948: E/Parcel(850):  at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4063)
11-14 05:19:51.948: E/Parcel(850):  at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159)
11-14 05:19:51.948: E/Parcel(850):  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2650)
11-14 05:19:51.948: E/Parcel(850):  at android.os.Binder.execTransact(Binder.java:404)
11-14 05:19:51.948: E/Parcel(850):  at dalvik.system.NativeStart.run(Native Method)
11-14 05:19:51.948: E/Parcel(850): Caused by: java.lang.NoClassDefFoundError: com/google/android/gms/maps/model/LatLng
11-14 05:19:51.948: E/Parcel(850):  ... 18 more
11-14 05:19:51.948: E/Parcel(850): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.model.LatLng" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
11-14 05:19:51.948: E/Parcel(850):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
11-14 05:19:51.948: E/Parcel(850):  at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
11-14 05:19:51.948: E/Parcel(850):  at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
11-14 05:19:51.948: E/Parcel(850):  ... 18 more
11-14 05:19:51.948: V/AudioPolicyManagerBase(264): setOutputDevice() prevDevice (0002)
11-14 05:19:51.948: V/AudioPolicyManagerBase(264): setOutputDevice() setting same device 0002 or null device for output 3
11-14 05:19:51.958: E/AudioResampler(264): Unsupported sample format, 1 bits, 2 channels

Please help me in resolving this issue. Thanks for your time

回答1:

I think you forgot to add google play services as a library.

You can use the following link to add it: http://developer.android.com/google/play-services/setup.html