Android 在其他片段中显示GoogleMaps时出错,缺少预期的资源:';R.string.google#u app#u id';

Android 在其他片段中显示GoogleMaps时出错,缺少预期的资源:';R.string.google#u app#u id';,android,google-maps,Android,Google Maps,我用谷歌地图活动创建了一个新项目,生成了密钥,一切正常。问题是我想在另一个片段中创建映射,因此下面是代码: MapsActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); // Obtain the SupportMapFragment

我用谷歌地图活动创建了一个新项目,生成了密钥,一切正常。问题是我想在另一个片段中创建映射,因此下面是代码:
MapsActivity

@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.
    if (savedInstanceState == null) {
        getSupportFragmentManager()
                .beginTransaction()
                .add(R.id.map, Fragment1.newInstance(), "Fragment1")
                .commit();
    }
}
碎片1类

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    view = inflater.inflate(R.layout.fragment1, container, false);
    mMap = (MapView) view.findViewById(R.id.map);
    mMap.getMapAsync(this);
    // Passing harcoded values for latitude & longitude. Please change as per your need. This is just used to drop a Marker on the Map
return  view;
}
@Override
public void onMapReady(GoogleMap map) {
    map.addMarker(new MarkerOptions()
            .position(new LatLng(0, 0))
            .title("Marker"));
}
现在我明白了这个错误


GoogleService未能初始化,状态:10,缺少用于初始化google服务的预期资源:“R.string.google\u app\u id”。可能的原因是缺少google-services.json或com.google.gms.google-services gradle插件

项目中是否有您的
google services.json
?你的
strings.xml
是什么样子的?是的,我有
.json
,在
strings.xml中我有
xxxxxx`和我的ID。你的
google services.json
项目中有吗?你的
strings.xml
是什么样子的?是的,我有
.json
,在
strings.xml中我有
xxxxxx`和我的id