简体   繁体   English

在android上使用google drive api_key

[英]use google drive api_key on android

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 ) 创建了一个新的api密钥,将其限制为android app,在AndroidManifest.xml中添加了我的包名(package =“XXXX.YYYY”字段中的manifest标签),添加了我的SHA1(使用此命令keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v
  • added INTERNET, ACCESS_NETWORK_STATE and GET_ACCOUNTS permissions in my AndroidManifest.xml 在我的AndroidManifest.xml中添加了INTERNET,ACCESS_NETWORK_STATE和GET_ACCOUNTS权限
  • 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 在AndroidManifest.xml中的应用程序标记内添加<meta-data android:name="com.google.android.apps.drive.APP_ID" android:value="id=My_Key_copied_from_google_devel_console" />
  • added this dep in gradle: compile 'com.google.android.gms:play-services-drive:9.0.0' 在gradle中添加了这个dep: compile 'com.google.android.gms:play-services-drive:9.0.0'
  • created a new activity and copy-pasted MainActivity from quickstart example from google 从google的quickstart示例创建了一个新活动和复制粘贴的MainActivity

now i get this error when i click on my accout to authenticate it: 现在,当我点击我的accout进行身份验证时,我收到此错误:

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. 我正在测试Android模拟器5.0 x86_64与谷歌apis。

where am I doing wrong? 我哪里做错了?

EDIT: as Bertrand Martel pointed out i must sign my apk, but still no luck. 编辑:正如Bertrand Martel指出我必须签署我的apk,但仍然没有运气。

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.

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. 使用我的SHA1和程序包名称在Google开发人员控制台中创建ID客户端OAuth 2.0。

EDIT: 编辑:

after some testing API KEY isn't needed, only ID client OAuth 2.0 经过一些测试后,不需要API KEY,只有ID客户端OAuth 2.0

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

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