Java 错误:类SupportMapFragment中的getMapAsync方法无法应用于给定类型;

Java 错误:类SupportMapFragment中的getMapAsync方法无法应用于给定类型;,java,Java,我得到了这个错误 错误:类SupportMapFragment中的方法getMapAsync不能为空 适用于给定类型;必需:OnMapReadyCallback找到:否 参数原因:实际参数列表和正式参数列表长度不同 错误:无法访问的zzbgl类文件 找不到com.google.android.gms.internal.zzbgl 在MapDirectionDisplayActivity.java文件中 这是我的密码 private void getLastActivityInfo() {

我得到了这个错误

错误:类SupportMapFragment中的方法getMapAsync不能为空 适用于给定类型;必需:OnMapReadyCallback找到:否 参数原因:实际参数列表和正式参数列表长度不同

错误:无法访问的zzbgl类文件 找不到com.google.android.gms.internal.zzbgl

在MapDirectionDisplayActivity.java文件中

这是我的密码

private void getLastActivityInfo() 
{
    lastActivityData = getIntent().getExtras();
}

private void setUpMapIfNeeded() {
    if (mapView == null) 
    {
        mapView = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        if (mapView != null) 
        {
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(lastActivityData.getDouble("point_one_lat")
                    , lastActivityData.getDouble("point_one_lon")), 15);
            mapView.animateCamera(cameraUpdate);
        }
    }

    new DirectionLoadingThread().execute();
}


@Override
public void onBackPressed() {
    finish();
    super.onBackPressed();

}
@Override
protected void onResume() {

    try {
        if(gpsTracker!=null)
            gpsTracker.loctionUpdate();
    } catch (Exception e) {
    }
    super.onResume();
}
@Override
public void finish() {
    try {
        if(gpsTracker!=null)
        {
            gpsTracker.stopUsingGPS();
            gpsTracker.stopSelf();
        }

    } catch (Exception e) {
    }

    super.finish();
}
public class MyLocationListener implements LocationListener
{
    Context context;

    MyLocationListener(Context context)
    {
        this.context=context;
    }
    @Override
    public void onProviderDisabled(String provider)
    {
        Toast.makeText(context,"Gps Disabled",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onProviderEnabled(String provider)
    {
        Toast.makeText(context,"Gps Enabled",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras)
    {
    }

    @Override
    public void onLocationChanged(Location location)
    {
        double lat = location.getLatitude();
        double lng= location.getLongitude();
    }
}

private class DirectionLoadingThread extends AsyncTask<Void, Void, JSONArray>
{

    @Override
    protected JSONArray doInBackground(Void... arg0) {

        String apiUrl ="http://maps.googleapis.com/maps/api/directions/json?origin="+lastActivityData.getDouble("point_one_lat")+","+lastActivityData.getDouble("point_one_lon")
                +"&destination="+lastActivityData.getDouble("point_two_lat")
                +","+lastActivityData.getDouble("point_two_lon")+"&sensor=false";
                String result;
                try {
                    result  = CustomHttpClient.executeGet(apiUrl);
                    if(result!=null)
                    {
                        return new JSONObject(result).getJSONArray("routes").getJSONObject(0).getJSONArray("legs").getJSONObject(0).getJSONArray("steps");
                    }
                }catch (Exception e) {
                }
        return null;
    }

    @Override
    protected void onPostExecute(JSONArray resultArray) {
         if (mapView != null) 
            {
                mapView.addMarker(new MarkerOptions()
                .position(new LatLng(lastActivityData.getDouble("point_one_lat"), lastActivityData.getDouble("point_one_lon")))
                .title(lastActivityData.getString("point_location_one_title")));

                LatLng lastLonLat = new LatLng(lastActivityData.getDouble("point_one_lat"), lastActivityData.getDouble("point_one_lon"));
                if(resultArray!=null)
                {
                    LatLng newLonLat = null ;
                    for (int i = 0; i < resultArray.length(); i++) {

                        try {
                            newLonLat = new LatLng(resultArray.getJSONObject(i).getJSONObject("end_location").getDouble("lat")
                                    , resultArray.getJSONObject(i).getJSONObject("end_location").getDouble("lng"));
                            mapView.addPolyline(new PolylineOptions().add(lastLonLat
                            ,newLonLat)
                                    .width(3)
                                    .color(Color.BLUE));


                        } catch (JSONException e) {
                        }
                        lastLonLat = newLonLat;
                    }

                }

                mapView.addMarker(new MarkerOptions()
                .position(new LatLng(lastActivityData.getDouble("point_two_lat"), lastActivityData.getDouble("point_two_lon")))
                .title(lastActivityData.getString("point_location_two_title")));
            }
        super.onPostExecute(resultArray);
    }
}
private void getLastActivityInfo()
{
lastActivityData=getIntent().getExtras();
}
私有void setUpMapIfNeeded(){
如果(mapView==null)
{
mapView=((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
如果(地图视图!=null)
{
CameraUpdate CameraUpdate=CameraUpdateFactory.newLatLngZoom(newlatlng(lastActivityData.getDouble)(“一点一点”)
,lastActivityData.getDouble(“点”),15);
mapView.animateCamera(cameraUpdate);
}
}
new DirectionLoadingThread().execute();
}
@凌驾
public void onBackPressed(){
完成();
super.onBackPressed();
}
@凌驾
受保护的void onResume(){
试一试{
如果(gpsTracker!=null)
gpsTracker.locationUpdate();
}捕获(例外e){
}
super.onResume();
}
@凌驾
公共空间整理(){
试一试{
如果(gpsTracker!=null)
{
gpsTracker.停止使用GPS();
gpsTracker.stopSelf();
}
}捕获(例外e){
}
super.finish();
}
公共类MyLocationListener实现LocationListener
{
语境;
MyLocationListener(上下文)
{
this.context=context;
}
@凌驾
公共无效onProviderDisabled(字符串提供程序)
{
Toast.makeText(上下文,“Gps禁用”,Toast.LENGTH_SHORT).show();
}
@凌驾
公共无效onProviderEnabled(字符串提供程序)
{
Toast.makeText(上下文,“启用Gps”,Toast.LENGTH_SHORT).show();
}
@凌驾
public void onStatusChanged(字符串提供程序、int状态、Bundle extra)
{
}
@凌驾
已更改位置上的公共无效(位置)
{
双纬度=location.getLatitude();
double lng=location.getLongitude();
}
}
私有类DirectionLoadingThread扩展异步任务
{
@凌驾
受保护的JSONArray doInBackground(无效…arg0){
字符串apiUrl=”http://maps.googleapis.com/maps/api/directions/json?origin=“+lastActivityData.getDouble”(“point_one_lat”)+”,“+lastActivityData.getDouble”(“point_one_lat”)
+“&destination=“+lastActivityData.getDouble”(“两点”)
+“,”+lastActivityData.getDouble(“点”+“&sensor=false”);
字符串结果;
试一试{
结果=CustomHttpClient.executeGet(apiUrl);
如果(结果!=null)
{
返回新的JSONObject(结果)。getJSONArray(“路由”)。getJSONObject(0)。getJSONArray(“腿”)。getJSONObject(0)。getJSONArray(“步骤”);
}
}捕获(例外e){
}
返回null;
}
@凌驾
受保护的void onPostExecute(JSONArray结果数组){
如果(地图视图!=null)
{
addMarker(新的MarkerOptions()
.position(新LatLng(lastActivityData.getDouble(“point\u one\u lat”)、lastActivityData.getDouble(“point\u one\u lon”))
.title(lastActivityData.getString(“点位置一个标题”);
LatLng lastLonLat=新LatLng(lastActivityData.getDouble(“point_one_lat”)、lastActivityData.getDouble(“point_one_lon”);
if(resultArray!=null)
{
LatLng newLonLat=null;
对于(int i=0;i
}捕获(异常e){}如果不处理异常,就永远不会捕获它,。至少把它们记录下来。也不要捕捉基类异常,只捕捉子类。我对android开发完全陌生,只是在学习。我不明白你的意思