Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android.view.InflateException:二进制XML文件行#7:膨胀类片段时出错?_Android_Fragment_Android Mapview - Fatal编程技术网

android.view.InflateException:二进制XML文件行#7:膨胀类片段时出错?

android.view.InflateException:二进制XML文件行#7:膨胀类片段时出错?,android,fragment,android-mapview,Android,Fragment,Android Mapview,我试图将一个映射作为ActionBarActivity中的一个片段加载到我的应用程序中。它在某些设备上运行良好,我可以看到地图、放大和缩小……等等,但在某些设备上,我收到一条崩溃消息,上面说: 2153-2188/com.mahmoud.android.MoadenLibya W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 6587000 but found 4324038 06-03 21:38:05.

我试图将一个映射作为ActionBarActivity中的一个片段加载到我的应用程序中。它在某些设备上运行良好,我可以看到地图、放大和缩小……等等,但在某些设备上,我收到一条崩溃消息,上面说:

2153-2188/com.mahmoud.android.MoadenLibya W/GooglePlayServicesUtil﹕ Google Play services out of date.  Requires 6587000 but found 4324038
06-03 21:38:05.869    2153-2153/com.mahmoud.android.MoadenLibya V/mbg﹕ onPause
06-03 21:38:05.879    2153-2153/com.mahmoud.android.MoadenLibya D/SensorManager﹕ unregisterListener ::
06-03 21:38:05.889    2153-2153/com.mahmoud.android.MoadenLibya W/ApplicationPackageManager﹕ getCSCPackageItemText()
06-03 21:38:05.889    2153-2153/com.mahmoud.android.MoadenLibya I/PersonaManager﹕ getPersonaService() name persona_policy
06-03 21:38:05.899    2153-2153/com.mahmoud.android.MoadenLibya W/GooglePlayServicesUtil﹕ Google Play services out of date.  Requires 6587000 but found 4324038
06-03 21:38:05.904    2153-2153/com.mahmoud.android.MoadenLibya W/GooglePlayServicesUtil﹕ Google Play services out of date.  Requires 6587000 but found 4324038
06-03 21:38:05.909    2153-2153/com.mahmoud.android.MoadenLibya W/GooglePlayServicesUtil﹕ Google Play services out of date.  Requires 6587000 but found 4324038
06-03 21:38:05.909    2153-2153/com.mahmoud.android.MoadenLibya D/AndroidRuntime﹕ Shutting down VM
06-03 21:38:05.909    2153-2153/com.mahmoud.android.MoadenLibya W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41808c08)
06-03 21:38:06.049    2153-2182/com.mahmoud.android.MoadenLibya D/dalvikvm﹕ GC_FOR_ALLOC freed 4921K, 15% free 40586K/47216K, paused 31ms, total 31ms
06-03 21:38:06.064    2153-2153/com.mahmoud.android.MoadenLibya E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.mahmoud.android.MoadenLibya, PID: 2153
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mahmoud.android.MoadenLibya/com.mahmoud.android.MoadenLibya.Mosque.Mosque}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
            at android.app.ActivityThread.access$900(ActivityThread.java:161)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5356)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
            at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
            at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
            at com.mahmoud.android.MoadenLibya.Mosque.Mosque.onCreate(Mosque.java:24)
            at android.app.Activity.performCreate(Activity.java:5431)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
            at android.app.ActivityThread.access$900(ActivityThread.java:161)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5356)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.mahmoud.android.MoadenLibya.Mosque.MosqueFragment.onCreateView(MosqueFragment.java:73)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:920)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
            at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1206)
            at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2159)
            at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
            at android.support.v7.app.ActionBarActivity.onCreateView(ActionBarActivity.java:547)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
            at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
            at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
            at com.mahmoud.android.MoadenLibya.Mosque.Mosque.onCreate(Mosque.java:24)
            at android.app.Activity.performCreate(Activity.java:5431)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
            at android.app.ActivityThread.access$900(ActivityThread.java:161)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5356)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)
这是我的完整代码:

在MainActivity类中,我加载一个名为“Mosque”的活动:

清真寺

package com.mahmoud.android.MoadenLibya.Mosque;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import com.mahmoud.android.MoadenLibya.R;


public class Mosque extends ActionBarActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.mosque);

    }

}
Mosque.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"

    tools:context=".Mosque">

    <fragment
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.mahmoud.android.MoadenLibya.Mosque.MosqueFragment"
        android:id="@+id/fragment"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"/>


</RelativeLayout>

麝香碎片

package com.mahmoud.android.MoadenLibya.Mosque;

import android.app.ProgressDialog;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.mahmoud.android.MoadenLibya.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.model.Marker;


import java.util.ArrayList;


public class MosqueFragment extends Fragment {

    MapView mapView;
    public static GoogleMap map;
    Location myLocation;
    LocationManager locationManager;
    LocationListener locationListener;
    private ArrayList<MosqueObject> mosquesArray;
    ProgressDialog mDialog;
    ArrayList<Marker> markers;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


        View v = inflater.inflate(R.layout.mosque_fragment, container, false);

        // Gets the MapView from the XML layout and creates it
        mapView = (MapView) v.findViewById(R.id.fragment);
        mapView.onCreate(savedInstanceState);

        locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);

        // Gets to GoogleMap from the MapView and does initialization stuff
        map = mapView.getMap();
        map.getUiSettings().setMyLocationButtonEnabled(true);
        map.setMyLocationEnabled(true);
        map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
        map.setInfoWindowAdapter(new PopupAdapter(getActivity().getLayoutInflater()));

        // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
        try {
            MapsInitializer.initialize(this.getActivity());
        } catch (Exception e) {
            e.printStackTrace();
        }



        return v;
    }




    @Override
    public void onResume() {
        mapView.onResume();
        super.onResume();
    }

    @Override
    public void onDestroy() {

        super.onDestroy();
        mapView.onDestroy();
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        mapView.onLowMemory();
    }




}
package com.mahmoud.android.moadenlibia.Mosque;
导入android.app.ProgressDialog;
导入android.content.Context;
导入android.location.location;
导入android.location.LocationListener;
导入android.location.LocationManager;
导入android.os.Bundle;
导入android.support.v4.app.Fragment;
导入android.view.LayoutInflater;
导入android.view.view;
导入android.view.ViewGroup;
导入com.mahmoud.android.moadenlibia.R;
导入com.google.android.gms.maps.GoogleMap;
导入com.google.android.gms.maps.MapView;
导入com.google.android.gms.maps.mapsintializer;
导入com.google.android.gms.maps.model.Marker;
导入java.util.ArrayList;
公共类MosqueFragment扩展了片段{
地图视图;
公共静态谷歌地图;
位置;
地点经理地点经理;
LocationListener LocationListener;
私人ArrayList mosquesArray;
进步对话;
阵列列表标记;
@凌驾
CreateView上的公共视图(布局、充气机、视图组容器、捆绑包保存状态){
视图v=充气机。充气(R.layout.U碎片,容器,假);
//从XML布局获取映射视图并创建它
mapView=(mapView)v.findViewById(R.id.fragment);
onCreate(savedInstanceState);
locationManager=(locationManager)getActivity().getSystemService(Context.LOCATION\u服务);
//从MapView获取GoogleMap并执行初始化操作
map=mapView.getMap();
map.getUiSettings().setMyLocationButtonEnabled(true);
map.setMyLocationEnabled(true);
map.setMapType(谷歌地图.map_类型_卫星);
setInfoWindowAdapter(新的PopupAdapter(getActivity().getLayoutFlater());
//在执行任何CameraUpdateFactory调用之前,需要调用MapsInitializer
试一试{
初始化(this.getActivity());
}捕获(例外e){
e、 printStackTrace();
}
返回v;
}
@凌驾
恢复时公开作废(){
onResume();
super.onResume();
}
@凌驾
公共空间{
super.ondestory();
mapView.onDestroy();
}
@凌驾
public void onLowMemory(){
super.onLowMemory();
onLowMemory();
}
}
MosqueFragment.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.google.android.gms.maps.MapView android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>

那么是什么导致了错误的发生呢?希望有人能帮我解决这个问题
谢谢

请发布整个堆栈跟踪,包括跟踪com.mahmoud.android.moadenlibia.Moadenlibia.Mosque.Mosque.Mosque.onCreate(Mosque.java:24)com.mahmoud.android.Moadenlibia.Mosque.MosqueFragment.onCreateView(MosqueFragment.java:73)中紧跟着一组行的一个或多个“起因”部分java是主类,您在Mosque中持有MosqueFragment,但在Mosqueof child中没有引用fragment@MFaisalHyder你能详细解释一下你的意思吗?谢谢看这个例子:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.google.android.gms.maps.MapView android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>