嗨:)我有一些问题,包括我的Android应用程序中的谷歌地图。我一直在尝试一切,包括扩展MapActivity并将此行添加到我的项目清单<uses-library android:name="com.google.android.maps" />
。我仍然得到同样的错误。
这是logcat的输出。
12-05 00:03:23.472: E/AndroidRuntime(24182): FATAL EXCEPTION: main
12-05 00:03:23.472: E/AndroidRuntime(24182): Process: com.example.package, PID: 24182
12-05 00:03:23.472: E/AndroidRuntime(24182): java.lang.RuntimeException: Unable to start activity ComponentInfo{...map.Map}: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.android.gms.maps.MapView
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.ActivityThread.access$800(ActivityThread.java:144)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.os.Handler.dispatchMessage(Handler.java:102)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.os.Looper.loop(Looper.java:135)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.ActivityThread.main(ActivityThread.java:5221)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.reflect.Method.invoke(Native Method)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.reflect.Method.invoke(Method.java:372)
12-05 00:03:23.472: E/AndroidRuntime(24182): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
12-05 00:03:23.472: E/AndroidRuntime(24182): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
12-05 00:03:23.472: E/AndroidRuntime(24182): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.android.gms.maps.MapView
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.view.LayoutInflater.createView(LayoutInflater.java:633)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
12-05 00:03:23.472: E/AndroidRuntime(24182): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.Activity.setContentView(Activity.java:2144)
12-05 00:03:23.472: E/AndroidRuntime(24182): at ...map.Map.onCreate(Map.java:28)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.Activity.performCreate(Activity.java:5933)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
12-05 00:03:23.472: E/AndroidRuntime(24182): ... 10 more
12-05 00:03:23.472: E/AndroidRuntime(24182): Caused by: java.lang.reflect.InvocationTargetException
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.reflect.Constructor.newInstance(Native Method)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
12-05 00:03:23.472: E/AndroidRuntime(24182): at android.view.LayoutInflater.createView(LayoutInflater.java:607)
12-05 00:03:23.472: E/AndroidRuntime(24182): ... 21 more
12-05 00:03:23.472: E/AndroidRuntime(24182): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/R$styleable;
12-05 00:03:23.472: E/AndroidRuntime(24182): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
12-05 00:03:23.472: E/AndroidRuntime(24182): at com.google.android.gms.maps.MapView.<init>(Unknown Source)
12-05 00:03:23.472: E/AndroidRuntime(24182): ... 24 more
12-05 00:03:23.472: E/AndroidRuntime(24182): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.R$styleable" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/.../base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
12-05 00:03:23.472: E/AndroidRuntime(24182): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
12-05 00:03:23.472: E/AndroidRuntime(24182): ... 26 more
12-05 00:03:23.472: E/AndroidRuntime(24182): Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.R$styleable
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.Class.classForName(Native Method)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
12-05 00:03:23.472: E/AndroidRuntime(24182): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
12-05 00:03:23.472: E/AndroidRuntime(24182): ... 27 more
12-05 00:03:23.472: E/AndroidRuntime(24182): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
12-05 00:03:25.050: I/Process(24182): Sending signal. PID: 24182 SIG: 9
这是我到目前为止唯一的代码
public class Map extends MapActivity {
MapView map_view;
GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_map);
MapsInitializer.initialize(this);
map_view = (MapView) findViewById(R.id.map_view);
map_view.onCreate(savedInstanceState);
map = map_view.getMap();
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
代码似乎在此行崩溃:setContentView(R.layout.layout_map);
谢谢!