简体   繁体   English

引发Google Awareness Snapshot.getLocation SecurityException

[英]Google Awareness Snapshot.getLocation SecurityException is thrown

I know this seems like a duplicate of ( Google Awareness API SecurityException is thrown ) and it probably is but since my stackoverflow mojo isn't great enough I can't vote the question up or add comment and this is definitely not an answer. 我知道这似乎是( 引发Google Awareness API SecurityException )的重复,但是可能是这样,但是由于我的stackoverflow mojo不够好,所以我无法投票提出问题或添加评论,这绝对不是答案。 So I apologize in advance for the duplication. 因此,我对此表示歉意。

As in the case above I see about 10% my awareness api calls (120K successes + 1.2K failures) receive a SecurityException with a -1 response code, I followed the current responders suggestions to verify the package name matched the name registered in the Awareness API registration step and they do match. 如上例所示,我看到大约10%的感知api调用(成功12万次成功+ 1.2万次失败)收到带有-1响应代码的SecurityException,我按照当前响应者的建议来验证程序包名称与在“意识”中注册的名称匹配API注册步骤,它们确实匹配。 If fact if I force them to be different I get the same exception but with a 6 as a response code not a -1; 如果事实是如果我强迫它们不同的话,我会得到相同的异常,但响应代码为6,而不是-1; but this happens failure happens for every request not intermittently. 但是,这种情况并非每个请求都间歇地发生。 And when I look in the Google Awareness API overview in the developer console I see approximately the same number of crashes as the number of Server Error (5XX) responses. 当我在开发人员控制台中查看Google Awareness API概述时,发现崩溃的次数与服务器错误(5XX)响应的次数大致相同。

My question however is that if the Snapshot API offers method like 但是我的问题是,如果Snapshot API提供的方法类似于

public static PendingResult<LocationResult> getLocation(GoogleApiClient client)

where the use of this method cannot catch the SecurityException thrown by the code that it invokes as the exception occurs in a separate thread of internal code's own creation. 使用此方法无法捕获其调用的代码引发的SecurityException,因为该异常发生在内部代码自己创建的单独线程中。 Why doesn't the Awareness API code just catch that SecurityException and handle it as if the LocationResult is a failure instead of crashing my application? 为什么Awareness API代码不仅仅捕获该SecurityException并像LocationResult失败一样处理它,而不是崩溃我的应用程序?

from: https://code.google.com/p/android/issues/detail?id=223751 来自: https : //code.google.com/p/android/issues/detail?id=223751

There is a bug in our checks that is sometimes throwing this SecurityException when there is a network error to authenticate. 我们的检查中存在一个错误,当存在要验证的网络错误时,有时会引发此SecurityException。 The fix will rollout in the next version of Google Play services. 该修复程序将在下一版Google Play服务中推出。

For now, the best workaround would be set up an UncaughtExceptionHandler on the thread that you call GoogleApiClient.connect(). 现在,最好的解决方法是在调用GoogleApiClient.connect()的线程上设置UncaughtExceptionHandler。 For most folks, this would be on the main thread, which you can get via Looper.myLooper().getThread(). 对于大多数人来说,这将在主线程上,您可以通过Looper.myLooper()。getThread()获得该线程。

The SecurityException is thrown in the call to GoogleApiClient.connect(). 在对GoogleApiClient.connect()的调用中引发SecurityException。 Please see Google Awareness API SecurityException is thrown for workaround. 请参阅Google Awareness API SecurityException引发的解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM