我在运行Google Maps Android API Utility Demo时遇到问题,它显示以下错误:
04-03 16:32:37.397: E/dalvikvm(2592): Could not find class 'com.google.maps.android.utils.demo.ClusteringDemoActivity', referenced from method com.google.maps.android.utils.demo.MainActivity.onCreate
04-03 16:32:37.452: E/AndroidRuntime(2592): FATAL EXCEPTION: main
04-03 16:32:37.452: E/AndroidRuntime(2592): java.lang.NoClassDefFoundError: com.google.maps.android.utils.demo.ClusteringDemoActivity
04-03 16:32:37.452: E/AndroidRuntime(2592): at com.google.maps.android.utils.demo.MainActivity.onCreate(MainActivity.java:20)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.app.Activity.performCreate(Activity.java:5163)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.app.ActivityThread.access$600(ActivityThread.java:140)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.os.Looper.loop(Looper.java:137)
04-03 16:32:37.452: E/AndroidRuntime(2592): at android.app.ActivityThread.main(ActivityThread.java:4895)
04-03 16:32:37.452: E/AndroidRuntime(2592): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 16:32:37.452: E/AndroidRuntime(2592): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 16:32:37.452: E/AndroidRuntime(2592): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
04-03 16:32:37.452: E/AndroidRuntime(2592): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
04-03 16:32:37.452: E/AndroidRuntime(2592): at dalvik.system.NativeStart.main(Native Method)
虽然我按照安装演示中显示的步骤操作,但是包中存在 ClusteringDemoActivity 类。
答案 0 :(得分:7)
我通过将GoogleMapsUtil作为库添加到演示项目来解决了这个问题。
如果您在步骤参考https://developers.google.com/maps/documentation/android/utility/setup处的设置指南,请参阅实用程序演示应用程序中的实用程序库,执行以下操作:
答案 1 :(得分:1)
文档告诉您使用:
compile 'com.google.maps.android:android-maps-utils:0.4+'
使用它会产生错误。你必须使用android-maps-utils:0.3 +
compile 'com.google.maps.android:android-maps-utils:0.3+'
这将消除错误。