缺少位置或位置状态

时间:2017-09-08 12:58:24

标签: android google-play-services

我最近将Google Play Services更新为版本43.从版本10.0更新到gradle中的11.0,所以我可以reduce friction with new Location APIs。使用以下代码:

FusedLocationProviderClient client =
                LocationServices.getFusedLocationProviderClient( this );

        if ( ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_COARSE_LOCATION ) != PackageManager.PERMISSION_GRANTED )
        {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        client.requestLocationUpdates( LocationRequest.create(), new LocationCallback()
        {
            @Override
            public void onLocationResult( LocationResult locationResult )
            {

                double lat = locationResult.getLastLocation().getLatitude();
                double lng = locationResult.getLastLocation().getLongitude();

                Log.d( "LOCATION_XYZ", "onLocationResult: Latitude:" + lat + " Longitude:" + lng );
            }
    @Override
            public void onLocationAvailability( LocationAvailability locationAvailability )
            {
                super.onLocationAvailability( locationAvailability );
            }
        }, null );

一旦代码工作正常,那么突然的应用程序会不断崩溃堆栈跟踪:

    java.lang.IllegalStateException: 
Missing location or location status: 556648763, 554464808, 553821978, 560939479
                                                    at anza.a(:com.google.android.gms@11509430:214)


                                 at anyz.handleMessage(:com.google.android.gms@11509430:18)
                                                at mme.run(:com.google.android.gms@11509430:6)
                                                at mmo.run(:com.google.android.gms@11509430:25)
                                                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                at mrv.run(:com.google.android.gms@11509430)
                                                at java.lang.Thread.run(Thread.java:761)

通过查看,当我在日志中看到 gms 时,我没有给出任何提示,为什么会发生这种情况,我认为错误在Google Play Services内。但我不知道如何解决它。我尝试搜索SOF,但任何人都没有列出此问题,至少我的搜索结果显示了这个问题。

还有其他人面临这个问题吗?你是怎么解决的?

0 个答案:

没有答案