【问题标题】:Google Map not showing in real devices谷歌地图未在真实设备中显示
【发布时间】:2018-08-31 11:54:32
【问题描述】:

您好,我的谷歌地图有问题,它只能在模拟器上运行,而不能在真实设备上运行。

这是我的 google_map_api.xml:

<resources>
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIza...</string

还有我的清单:

        <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIza..." />

和我的班级:

public class MapsActivity extends Fragment implements OnMapReadyCallback {

private GoogleMap mMap;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity_maps, container, false);

    final SupportMapFragment map =  (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
    map.getMapAsync(this);

    return rootView;
}

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    try {
        boolean success = googleMap.setMapStyle(
                MapStyleOptions.loadRawResourceStyle(
                        this.getActivity(), R.raw.mapstyle));

    } catch (Resources.NotFoundException e) {

    }

         return true;
        }
    });
}

}

【问题讨论】:

标签: android google-maps


【解决方案1】:

请打印您的日志,但在此之前请检查您是否在线

【讨论】:

    【解决方案2】:

    您的 google_maps_key 必须使用您用来生成安装在设备中的 apk 的发布证书 (SHA-1) 进行注册

    here

    【讨论】:

      【解决方案3】:

      更改Google Maps API key,查看真机是否联网,设备minSdkVersion为21及以上。

      【讨论】:

        猜你喜欢
        • 2012-09-10
        • 1970-01-01
        • 2016-12-15
        • 2015-05-13
        • 2018-03-23
        • 1970-01-01
        • 1970-01-01
        • 2013-01-20
        • 1970-01-01
        相关资源
        最近更新 更多