Android 缺少位置或位置状态
我最近将Google Play Services更新为43版。在Android 缺少位置或位置状态,android,google-play-services,Android,Google Play Services,我最近将Google Play Services更新为43版。在gradle中从库的10.0版更新到11.0版,因此我可以。使用以下代码: FusedLocationProviderClient client = LocationServices.getFusedLocationProviderClient( this ); if ( ActivityCompat.checkSelfPermission( this, Manife
gradle
中从库的10.0版更新到11.0版,因此我可以。使用以下代码:
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
时,这并没有给出任何关于为什么会发生这种情况的提示,我假设错误在谷歌Play Services
中。但我不知道如何解决它。我尝试搜索软件,但这个问题并没有被任何人列出,至少我的搜索结果显示了这一点
还有其他人面临这个问题吗?您是如何解决的?我遇到了相同的问题,但在清单中添加Internet权限时出现了此错误。我已经添加了这些权限。我遇到了相同的问题,但在清单中添加Internet权限时出现了此错误。我已经添加了这些权限。