我正在将谷歌地图集成到我的应用程序中,它在kitkat设备中不起作用,但在棒棒糖版本中工作正常。我的代码是:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMap();
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
googleMap.setMyLocationEnabled(true);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
我收到了kitkat设备的以下错误消息。
getGoogleAppId failed with status: 10
Uploading is not possible. App measurement disabled
知道为什么会这样吗?
答案 0 :(得分:0)
尝试在manifest.xml文件中添加此行
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
并使用FragmentActivity扩展您的活动。
答案 1 :(得分:0)
我所做的是在我的Android设备中,我刚刚在地图中创建了一个帐户,接下来的事情就是打开了我的应用程序并开始工作了,:)