Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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 java.lang.NoSuchMethodError:com.boom.geolocationbased.MapView.getFragmentManager_Android - Fatal编程技术网

Android java.lang.NoSuchMethodError:com.boom.geolocationbased.MapView.getFragmentManager

Android java.lang.NoSuchMethodError:com.boom.geolocationbased.MapView.getFragmentManager,android,Android,我是android编程新手。我正在谷歌地图Api上工作。 我遵循了如何将GoogleAPI集成到项目中以及如何将GooglePlay服务添加为参考库的所有步骤 但是,当我试图在我的设备上运行我的项目时,它会向我显示这个错误 10-18 18:19:04.742: E/AndroidRuntime(8003): java.lang.NoSuchMethodError:com.boom.geolocationbased.MapView.getFragmentManager 我的清单文件是: <

我是android编程新手。我正在谷歌地图Api上工作。 我遵循了如何将GoogleAPI集成到项目中以及如何将GooglePlay服务添加为参考库的所有步骤

但是,当我试图在我的设备上运行我的项目时,它会向我显示这个错误

10-18 18:19:04.742: E/AndroidRuntime(8003): java.lang.NoSuchMethodError:com.boom.geolocationbased.MapView.getFragmentManager
我的清单文件是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.boom.geolocationbased"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="com.example.googlemaps.permission.MAPS_RECEIVE" />
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />
<permission
  android:name="com.boom.geolocationbased.permission.MAPS_RECIEVE"
  android:protectionLevel="signature" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.boom.geolocationbased.permission.MAPS_RECIEVE"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >


    <activity
        android:name="com.boom.geolocationbased.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="AIzaSyDHe4z6aw_UZbOM9fSLzucg_UfaOoDuJic"/>
    <meta-data 
    android:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version" />
    <service android:name="GPSTracker"></service>
    <activity android:name="MapView"></activity>

</application>

</manifest>

and here is my xml file for my mapactivity

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"/>
有人能帮我找出我的代码有什么问题吗


谢谢。

要获取谷歌地图,请尝试以下方法:

GoogleMap googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

您确定功能范围存在吗?是!我在上面的问题中提到过这段代码,但它出现了异常。我已经将这段代码写进了oncreate方法中。这样可以吗?还是我必须做些其他事情?您使用的是MapFragment还是MapView?我使用的是MapFragment。我也这样做了。。。。但每次我都会犯这个错误。。我的google服务库有什么问题吗?没有明显的原因,但请将指定名称的方式(如“MapView”)更改为“com.boom.geolocationbased.MapView”或“.MapView”,并尝试在定义活动的自定义名称时不使用关键字。
GoogleMap googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();