不兼容的类型。必填:找到GoogleApiClient:GoogleApiClient.Builder

时间:2016-12-04 16:49:32

标签: google-api-client

我正在尝试使用Google API客户端获取最后一个已知位置,但我遇到了与其不兼容的问题。谁能指出我错过了什么?

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, OnConnectionFailedListener,
        ConnectionCallbacks{

    private GoogleMap mMap;
    private GoogleApiClient mGoogleApiClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);

        // getting incompatible issue in below line
        mGoogleApiClient = new GoogleApiClient.Builder(this);

        // Obtain the SupportMapFragment and get notified when the map is ready           to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

1 个答案:

答案 0 :(得分:0)

试试这个。

        mGoogleApiClient = new GoogleApiClient.Builder(this).build();