Google Map API 10.2.6 - java.lang.RuntimeException:createContext failed:12291

时间:2017-05-21 16:17:13

标签: android google-maps

我已经从“新建项目”对话框中创建了一个简单的Google地图应用程序,我已经从Google API控制台中快速设置并接收了我的密钥。出于测试目的,我还下载了支持Google Play服务的全新Android N系统映像,如下所示:

enter image description here

无论我试图做什么,这个例外总会发生:

enter image description here

活动示例代码:

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.getMapAsync(this);
}


/**
 * 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);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}

}

我已完成我的研究,因为在未安装Google服务时,似乎会抛出此异常。但我保证他们是。如果我尝试在纯Android设备中安装它,该应用程序运行完全正常。

我错过了什么吗?

0 个答案:

没有答案