4

i followed a lot of tutorials, at the moment i have:

  • created a new project on google developer console
  • created a new api key, restricted it to android app, added my package name (package="XXXX.YYYY" field of manifest tag in AndroidManifest.xml), added my SHA1 (using this command keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v)
  • added INTERNET, ACCESS_NETWORK_STATE and GET_ACCOUNTS permissions in my AndroidManifest.xml
  • added <meta-data android:name="com.google.android.apps.drive.APP_ID" android:value="id=My_Key_copied_from_google_devel_console" /> inside application tag in AndroidManifest.xml
  • added this dep in gradle: compile 'com.google.android.gms:play-services-drive:9.0.0'
  • created a new activity and copy-pasted MainActivity from quickstart example from google

now i get this error when i click on my accout to authenticate it:

02-23 20:47:20.105 1931-2504/com.google.android.gms.persistent W/GLSUser: [AppCertManager] IOException while requesting key: 
                                                                          java.io.IOException: Invalid device key response.
                                                                              at enr.a(:com.google.android.gms:282)
                                                                              at enr.a(:com.google.android.gms:4237)
                                                                              at enq.a(:com.google.android.gms:46)
                                                                              at enk.a(:com.google.android.gms:53)
                                                                              at enj.a(:com.google.android.gms:111)
                                                                              at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms:4052)
                                                                              at dxg.call(:com.google.android.gms:2043)
                                                                              at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                              at kzi.run(:com.google.android.gms:450)
                                                                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                              at ldm.run(:com.google.android.gms:17)
                                                                              at java.lang.Thread.run(Thread.java:818)

i'm testing with android emulator 5.0 x86_64 with google apis.

where am I doing wrong?

EDIT: as Bertrand Martel pointed out i must sign my apk, but still no luck.

also here is a full log:

02-23 22:19:15.605 1493-1519/system_process I/ActivityManager: Displayed rmbq.patrol_one_v2.unbrand/rmbq.patrol_one_v2.WelcomeActivity: +84ms
02-23 22:19:15.623 3083-3100/rmbq.patrol_one_v2.unbrand D/OpenGLRenderer: endAllStagingAnimators on 0x7fc2591be400 (RippleDrawable) with handle 0x7fc25a73e660
02-23 22:19:16.997 1493-1559/system_process W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
02-23 22:19:16.997 1493-2523/system_process I/ActivityManager: START u0 {cmp=rmbq.patrol_one_v2.unbrand/rmbq.patrol_one_v2.SettingsActivity} from uid 10063 on display 0
02-23 22:19:17.022 1493-1657/system_process W/AppOps: Bad call: specified package com.google.android.gms under uid 10063 but it is really 10007
02-23 22:19:17.023 1493-1806/system_process W/AppOps: Bad call: specified package com.google.android.gms under uid 10063 but it is really 10007
02-23 22:19:17.023 1493-1941/system_process W/AppOps: Bad call: specified package com.google.android.gms under uid 10063 but it is really 10007
02-23 22:19:17.025 1493-1938/system_process W/AppOps: Bad call: specified package com.google.android.gms under uid 10063 but it is really 10007
02-23 22:19:17.055 1493-1519/system_process I/ActivityManager: Displayed rmbq.patrol_one_v2.unbrand/rmbq.patrol_one_v2.SettingsActivity: +58ms
02-23 22:19:17.081 1493-1508/system_process I/ActivityManager: START u0 {act=com.google.android.gms.signin.action.SIGN_IN cmp=com.google.android.gms/.signin.activity.SignInActivity (has extras)} from uid 10007 on display 0
02-23 22:19:17.083 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Loading activity implementation for ComponentInfo{com.google.android.gms/com.google.android.gms.signin.activity.SignInActivity}
02-23 22:19:17.083 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Proxying container activity ComponentInfo{com.google.android.gms/com.google.android.gms.signin.activity.SignInActivity} to Chimera activity impl .signin.activity.SignInChimeraActivity
02-23 22:19:17.090 1493-1807/system_process I/ActivityManager: START u0 {act=com.google.android.gms.common.account.CHOOSE_ACCOUNT_USERTILE pkg=com.google.android.gms cmp=com.google.android.gms/.common.account.AccountChipAccountPickerActivity (has extras)} from uid 10007 on display 0
02-23 22:19:17.111 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Loading activity implementation for ComponentInfo{com.google.android.gms/com.google.android.gms.common.account.AccountChipAccountPickerActivity}
02-23 22:19:17.111 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Proxying container activity ComponentInfo{com.google.android.gms/com.google.android.gms.common.account.AccountChipAccountPickerActivity} to Chimera activity impl .common.account.AccountChipAccountPickerChimeraActivity
02-23 22:19:17.151 1493-1519/system_process I/ActivityManager: Displayed com.google.android.gms/.common.account.AccountChipAccountPickerActivity: +58ms (total +69ms)
02-23 22:19:19.007 1493-1559/system_process W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
02-23 22:19:19.040 2481-2780/com.google.android.gms.ui D/OpenGLRenderer: endAllStagingAnimators on 0x7fc245fd7400 (ListView) with handle 0x7fc25aa627e0
02-23 22:19:19.059 2481-2481/com.google.android.gms.ui D/StrictMode: Wrote violation #0 of 3: 12720 bytes
02-23 22:19:19.061 2030-2044/com.google.android.gms D/StrictMode: Wrote violation #0 of 3: 13676 bytes
02-23 22:19:19.221 1120-1120/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
02-23 22:19:19.341 1889-2403/com.google.android.gms.persistent W/ContentTaskController: Invalid task was provided to stopTracking.
02-23 22:19:19.375 1493-1808/system_process W/AppOps: Bad call: specified package com.google.android.gms under uid 10063 but it is really 10007
02-23 22:19:19.381 1889-2220/com.google.android.gms.persistent I/art: Explicit concurrent mark sweep GC freed 55504(3MB) AllocSpace objects, 13(214KB) LOS objects, 30% free, 9MB/13MB, paused 136us total 12.142ms
02-23 22:19:19.383 1493-2523/system_process I/ActivityManager: START u0 {act=com.google.android.gms.signin.action.SIGN_IN cmp=com.google.android.gms/.signin.activity.SignInActivity (has extras)} from uid 10007 on display 0
02-23 22:19:19.386 1889-1889/com.google.android.gms.persistent W/GLSUser: [DeviceKeyStore] Cannot load key: Device key file not found.
02-23 22:19:19.391 1131-1530/? E/Drm: Failed to find drm plugin
02-23 22:19:19.391 2559-2904/com.google.android.gms.unstable W/DG.WV: Widevine DRM not supported on this device
                                                                      android.media.UnsupportedSchemeException: Failed to instantiate drm object.
                                                                          at android.media.MediaDrm.native_setup(Native Method)
                                                                          at android.media.MediaDrm.<init>(MediaDrm.java:180)
                                                                          at obk.a(:com.google.android.gms:119)
                                                                          at nyd.run(:com.google.android.gms:1092)
                                                                          at kzi.run(:com.google.android.gms:450)
                                                                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                          at ldm.run(:com.google.android.gms:17)
                                                                          at java.lang.Thread.run(Thread.java:818)
02-23 22:19:19.392 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Loading activity implementation for ComponentInfo{com.google.android.gms/com.google.android.gms.signin.activity.SignInActivity}
02-23 22:19:19.392 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Proxying container activity ComponentInfo{com.google.android.gms/com.google.android.gms.signin.activity.SignInActivity} to Chimera activity impl .signin.activity.SignInChimeraActivity
02-23 22:19:19.393 1493-1657/system_process I/ActivityManager: START u0 {act=com.google.android.gms.common.account.CHOOSE_ACCOUNT_USERTILE pkg=com.google.android.gms cmp=com.google.android.gms/.common.account.AccountChipAccountPickerActivity (has extras)} from uid 10007 on display 0
02-23 22:19:19.411 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Loading activity implementation for ComponentInfo{com.google.android.gms/com.google.android.gms.common.account.AccountChipAccountPickerActivity}
02-23 22:19:19.411 2481-2481/com.google.android.gms.ui D/ChimeraActivityProxy: Proxying container activity ComponentInfo{com.google.android.gms/com.google.android.gms.common.account.AccountChipAccountPickerActivity} to Chimera activity impl .common.account.AccountChipAccountPickerChimeraActivity
02-23 22:19:19.412 2481-2481/com.google.android.gms.ui D/StrictMode: Wrote violation #0 of 3: 16236 bytes
02-23 22:19:19.453 1493-1519/system_process I/ActivityManager: Displayed com.google.android.gms/.common.account.AccountChipAccountPickerActivity: +58ms (total +70ms)
02-23 22:19:20.164 1493-1571/system_process D/TaskPersister: removeObsoleteFile: deleting file=135_task.xml
02-23 22:19:20.164 1493-1571/system_process D/TaskPersister: removeObsoleteFile: deleting file=135_task_thumbnail.png
02-23 22:19:21.876 1889-2478/com.google.android.gms.persistent W/Conscrypt: Could not set socket write timeout: null
02-23 22:19:21.911 1889-2478/com.google.android.gms.persistent W/Conscrypt: Could not set socket write timeout: null
02-23 22:19:22.311 1889-2478/com.google.android.gms.persistent W/GLSUser: [AppCertManager] IOException while requesting key: 
                                                                          java.io.IOException: Invalid device key response.
                                                                              at enr.a(:com.google.android.gms:282)
                                                                              at enr.a(:com.google.android.gms:4237)
                                                                              at enq.a(:com.google.android.gms:46)
                                                                              at enk.a(:com.google.android.gms:53)
                                                                              at enj.a(:com.google.android.gms:111)
                                                                              at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms:4052)
                                                                              at dxg.call(:com.google.android.gms:2043)
                                                                              at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                              at kzi.run(:com.google.android.gms:450)
                                                                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                              at ldm.run(:com.google.android.gms:17)
                                                                              at java.lang.Thread.run(Thread.java:818)
02-23 22:19:22.312 1889-2403/com.google.android.gms.persistent W/ContentTaskController: Invalid newTask was provided to startTracking.
rmbq
  • 427
  • 4
  • 20
  • Did you sign your app with keystore you have generated with `keytool` previously ? If you are running the debug version make sure it is also signed – Bertrand Martel Feb 23 '17 at 20:40
  • no, thank you! but still no luck – rmbq Feb 23 '17 at 21:24
  • Check this [tutorial](https://www.numetriclabz.com/integrate-google-drive-in-android-tutorial/) on how to Integrate Google Drive in Android. You will learn here the step by step procedure on how to use the API key in your application. So try to double check here if you did the right thing. This [official documentation](https://developers.google.com/drive/android/auth) might also help. I also found out that error [Invalid device key response](https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/201) is error in SHA1 key. – KENdi Feb 24 '17 at 14:29

1 Answers1

0

all steps in my question were correct but i was missing one:

create an ID client OAuth 2.0 in google developer console with my SHA1 and package name.

EDIT:

after some testing API KEY isn't needed, only ID client OAuth 2.0

rmbq
  • 427
  • 4
  • 20