引发Google Awareness API SecurityException [英] Google Awareness API SecurityException is thrown

查看:292
本文介绍了引发Google Awareness API SecurityException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 DetectedActivityFence ="https://developers.google.com/awareness/"> Google Awareness API .在我自己的设备上运行正常,但是我在Crashlytics中遇到了一些有关 SecurityException 的崩溃.

I'm using DetectedActivityFence from Google Awareness API. It's working fine on my own devices, but I received a several crashes in Crashlytics about SecurityException.

Fatal Exception: java.lang.SecurityException: Invalid API Key for package = [package_name] .Status code received = -1
   at android.os.Parcel.readException(Parcel.java:1540)
   at android.os.Parcel.readException(Parcel.java:1493)
   at com.google.android.gms.common.internal.zzu$zza$zza.zza(Unknown Source)
   at com.google.android.gms.common.internal.zzd.zzqz(Unknown Source)
   at com.google.android.gms.internal.zzpw$zzc.zzapl(Unknown Source)
   at com.google.android.gms.internal.zzpw$zzf.run(Unknown Source)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
   at com.google.android.gms.internal.zzrn.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:818)

这种情况在Android版本之间没有任何关联,即会影响来自不同制造商和不同Android版本(5.x-6.x)的设备.这些设备不是扎根的,看起来像是在Stock ROM上工作.我的用户中有10%会出现此问题.

This happened without any correlations between Android versions, i.e. it affects devices from different manufacturers and different Android versions(5.x-6.x). These devices aren't rooted and look like working on Stock ROM. This problem appears for 10% of my users.

我确定我使用的API密钥正确,否则我可以在自己的设备上看到崩溃,可以吗?

I'm sure that I'm using the right API key otherwise I can see the crash on my own device, can I?

有人遇到过同样的问题吗?

Did anybody face the same issue?

推荐答案

存在一个错误,该错误错误地将网络操作中的一些错误误认为是对应用程序进行身份验证,以表明未正确设置API密钥.错误是另外一回事.该问题已在内部修复,并将在下一个Google Play服务版本中推广.

There is a bug that erroneously mistakes some errors from the network operation to authenticate the app as indicating that the API key was not set up correctly, even though the actual error was something else. This has been fixed internally and will roll out in the next Google Play services release.

目前,最好的解决方法是在调用GoogleApiClient.connect()的线程上添加UncaughtExceptionHandler.如果在主线程上调用GoogleApiClient.connect(),则可以通过Looper.myLooper().getThread()获取Thread实例.

For now, the best workaround is to add an UncaughtExceptionHandler on the thread that calls GoogleApiClient.connect(). If you call GoogleApiClient.connect() on the main thread, then you can get the Thread instance via Looper.myLooper().getThread().

这篇关于引发Google Awareness API SecurityException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆