MapView
当我尝试创建一个片段以保存它崩溃说找不到类时,我正在尝试创建一个包含 a 的布局以及其他项目(是的,我确实导入了谷歌播放服务库)
错误:
03-08 13:48:01.593: E/AndroidRuntime(30614): android.view.InflateException: Binary XML file line #7: Error inflating class com.google.android.gms.maps.MapView
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-08 13:48:01.593: E/AndroidRuntime(30614): at com.ecm2.mobilemap.fragments.CurrentIncidentMapFrag.onCreateView(CurrentIncidentMapFrag.java:16)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.app.Fragment.performCreateView(Fragment.java:1695)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.app.BackStackRecord.run(BackStackRecord.java:682)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.os.Handler.handleCallback(Handler.java:725)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.os.Handler.dispatchMessage(Handler.java:92)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.os.Looper.loop(Looper.java:137)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-08 13:48:01.593: E/AndroidRuntime(30614): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 13:48:01.593: E/AndroidRuntime(30614): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 13:48:01.593: E/AndroidRuntime(30614): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-08 13:48:01.593: E/AndroidRuntime(30614): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-08 13:48:01.593: E/AndroidRuntime(30614): at dalvik.system.NativeStart.main(Native Method)
03-08 13:48:01.593: E/AndroidRuntime(30614): Caused by: java.lang.reflect.InvocationTargetException
03-08 13:48:01.593: E/AndroidRuntime(30614): at java.lang.reflect.Constructor.constructNative(Native Method)
03-08 13:48:01.593: E/AndroidRuntime(30614): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-08 13:48:01.593: E/AndroidRuntime(30614): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-08 13:48:01.593: E/AndroidRuntime(30614): ... 20 more
03-08 13:48:01.593: E/AndroidRuntime(30614): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
03-08 13:48:01.593: E/AndroidRuntime(30614): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
03-08 13:48:01.593: E/AndroidRuntime(30614): at com.google.android.gms.maps.MapView.<init>(Unknown Source)
布局xml:(布局会改变我只是想让地图先工作)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
和我的片段
public class CurrentIncidentMapFrag extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle saved){
View v = inflater.inflate(R.layout.current_incident_mapping_layout,container,false);
return v;
}
}
我知道有一个地图片段,但我想要的不仅仅是一张地图,而且我不希望它占据片段中的整个视图,所以一个包含所有内容的视图片段是我唯一的选择。
我怎样才能让地图显示出来?