2016-09-11 23 views
0

我知道這似乎是一個重複的(Google Awareness API SecurityException is thrown),它可能是但自從我的stackoverflow mojo不夠大我不能投票提出問題或添加評論,這是絕對不是答案。所以我提前爲重複道歉。Google Awareness Snapshot.getLocation SecurityException拋出

與上面的情況一樣,我看到大約10%的意識api調用(120K成功+1.2K失敗)接收到帶有-1響應代碼的SecurityException,我遵循當前響應者的建議來驗證包名匹配名稱在Awareness API註冊步驟中註冊並且它們匹配。如果事實,如果我強迫他們不同,我得到同樣的例外,但與6作爲響應代碼不是-1;但是這種情況會發生,而不是間歇性地發生。當我在開發人員控制檯中查看Google Awareness API概述時,發現與服務器錯誤(5XX)響應數量大致相同的崩潰數量。

但我的問題是,如果快照API提供的方法類似

public static PendingResult<LocationResult> getLocation(GoogleApiClient client) 

在使用這種方法不能趕上由它調用在內部一個獨立的線程中發生異常的代碼拋出的拋出:SecurityException代碼自己的創作。爲什麼Awareness API代碼沒有捕獲到SecurityException,並將其作爲LocationResult失敗而不是崩潰我的應用程序來處理?

+0

我使用api提示並看到類似的行爲,並打開此問題:https://code.google.com/p/android/issues/update.do?id=223751#makechanges 您是否找到解決方案? –

回答

0

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

有一個在我們的檢查是有時拋出此拋出:SecurityException當出現網絡錯誤來驗證錯誤。該修補程序將在下一版Google Play服務中推出。

現在,最好的解決方法是在調用GoogleApiClient.connect()的線程上設置一個UncaughtExceptionHandler。對於大多數人來說,這將在主線程上,您可以通過Looper.myLooper()。getThread()獲取。

+0

另請參閱:http://stackoverflow.com/questions/39390557/google-awareness-api-securityexception-is-thrown –

相關問題