Google Awareness API SecurityException throws

I am using DetectedActivityFence from the Google Awareness API . It works fine on my own devices, but I got a few Crashlytics crashes 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) 

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

I am sure that I am using the correct API key, otherwise I can see a failure on my own device, can I?

Has anyone encountered the same problem?

+7
android google-awareness
source share
4 answers

There is an error that mistakenly accepts some errors from the network operation to authenticate the application, indicating that the API key was configured incorrectly, although the actual error was something else. This has been fixed internally and will be released in the next release of Google Play Services.

Currently, the best solution is to add an UncaughtExceptionHandler to the stream, which calls GoogleApiClient.connect (). If you call GoogleApiClient.connect () in the main thread, you can get an instance of Thread through Looper.myLooper (). GetThread ().

+5
source share

From: https://code.google.com/p/android/issues/detail?id=223751#c2

There is an error in our checks that sometimes throws this SecurityException when there is a network error for authentication. the fix will be introduced in the next version of Google Play services.

Currently, the best solution would be UncaughtExceptionHandler in the thread you are calling GoogleApiClient.connect (). For most people, this would be something you can get through Looper.myLooper (). getThread ().

But you will also notice that the answers indicate that this is not an easy job.

You may also notice that the OP of this stream refers to this SO record, but the accepted answer does not return a link to the stream, although they copied it verbatim. Very bad shape!

0
source share

I ran into this problem because I had the same error, and I thought that it could be Awareness API keys that do not sync with the Google Developer Console, after a lot of searching and getting the same error, I returned to the API recognition in Google Developer Console implemented my Awareness API, although I installed the package and had a valid API key. Also make sure the API key is installed in your manifest. Hope this helps someone.

0
source share

I struggled almost the whole day and found a different answer. Although the accepted answer was correct at the time.

The only thing that helped me create the API key in the Google Developer Console using the debug keystore for testing purposes and replace it with the keystore when I went into production.

How to generate an API key? Please read the word google itself here.

Hope this helps someone in the future.

0
source share

All Articles