发布模式下 SupportMapFragment 中出现“Google Play 服务正在更新”消息

5

我在Google Maps上遇到了一个奇怪的问题。

当我处于调试模式时,一切都正常,但当我处于发布模式时,onMapReady回调函数从未被调用,地图会显示“Google Play服务正在更新”的消息。

另一个奇怪的事情是,如果我在应用程序启动时运行一个带有地图的活动,则即使在其他活动中也可以正常工作。

以下是我在片段中的代码

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

    FrameLayout fr = (FrameLayout) inflater.inflate(R.layout.my_fragment, null);
    //views code

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

    return fr;
}

你弄清楚这是为什么了吗?我也遇到了完全相同的问题。谢谢。 - MLN
很不幸,我没有。只有在第一个活动(启动器活动)中加载虚假地图时,它才能在发布模式下工作。也许与其他Play服务相关的一些错误。 - Bronx
现在正在面临同样的问题!有任何消息吗? - Chris
2个回答

0

尝试将此行添加到proguard规则文件中

-keep class com.google. ** {*; }

希望能有所帮助


目前Proguard已禁用,因此这不是与Proguard相关的问题。 - Bronx

0
将我所有的 Google Play 依赖项降级到 10.0.1 对我有用。请参见以下内容:
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.android.gms:play-services-analytics:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'

不幸的是,我仍在使用10.0.1版本,即使降级到9.6.0或9.8.0也无法解决问题。 - Bronx

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接