【发布时间】:2017-01-16 12:58:54
【问题描述】:
我正在尝试构建一个集成了 google drive api 并将驱动器用作它的存储存储的 android 应用程序,但是我从一开始就遇到了问题。 我一直在尝试遵循以下官方指南: https://developers.google.com/drive/android/get-started 以及我找到的另一个指南https://www.numetriclabz.com/integrate-google-drive-in-android-tutorial/,甚至下载了源代码并只是替换了我的 API 密钥,但是使用这两个指南我遇到了完全相同的问题。
每当我尝试测试运行应用程序以查看应用程序是否连接到驱动器时,我都会在控制台中获得以下输出:
$ adb shell am start -n "app.googledrive/app.googledrive.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Connected to process 2889 on device emulator-5554
W/System: ClassLoader referenced unknown path: /data/app/app.googledrive-1/lib/x86
I/InstantRun: Instant Run Runtime started. Android package is app.googledrive, real application class is null.
[ 01-16 12:33:01.211 1561: 1584 D/ ]
HostConnection::get() New Host Connection established 0x953a3740, tid 1584
W/System: ClassLoader referenced unknown path: /data/app/app.googledrive-1/lib/x86
I/GMPM: App measurement is starting up, version: 8487
I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
E/EGL_emulation: tid 2930: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x94efd500, error=EGL_BAD_MATCH
I/Google Drive Activity: GoogleApiClient connection failed: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{e061739: android.os.BinderProxy@2c1717e}, message=null}
此外,还会弹出 Google 登录以向我添加帐户,这意味着它连接到 Google 服务器,但由于某种原因无法识别帐户/登录。我还尝试重新生成密钥库并将其再次添加到开发人员控制台并使用不受限制的密钥,但是出现了同样的问题。
非常感谢任何有关如何解决此问题的帮助或建议,谢谢。
【问题讨论】:
-
在设备上试试,可能是模拟器登录有问题
-
感谢@avinash 的建议。我确实尝试直接在 android 设备上运行它,但是它仍然不允许我选择一个帐户并继续,因为每当我在设备中单击我的帐户时,android studio 中仍然会出现以下消息:
-
01-17 13:35:13.375 9923-9923/app.googledrive D/AppTracker: App Event: start 01-17 13:35:13.413 9923-9923/app.googledrive I/Google Drive Activity: GoogleApiClient connection failed: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{a77a4d3: android.os.BinderProxy@3009081}, message=null} 01-17 13:35:13.429 9923-9923/app.googledrive D/AppTracker: App Event: stop 01-17 13:35:13.445 9923-9923/app.googledrive D/AbstractTracker: Event success 01-17 13:35:13.463 9923-9923/app.googledrive D/AbstractTracker: Event success -
奇怪我使用了来自developers.google.com/drive/android/get-started的样本,但没有问题。是否可以发布您的代码,并确保在控制台上启用 API
标签: android android-studio google-api google-drive-api google-drive-android-api