问题
I am trying to build an android app that integrates google drive api and uses the drive as the storage storage for it however I am after running into issue with it from the very beginning. I've been trying to follow the official guide available at: https://developers.google.com/drive/android/get-started and also another guide I found https://www.numetriclabz.com/integrate-google-drive-in-android-tutorial/ and even downloading the source code and just replacing my API Key however with both of these guides I run into the exact same issue.
Whenever I try to test run the app to see if the app is connecting to the drive i get the following output in the console:
$ 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}
Also the Google Sign in is popping up to add an account to me it means that it connects to the google server but doesn't recognize account/sign in for one or the other reason. I've also tried regenerating the keystore and adding it again to the developers console and using an unrestricted key however the same exact issue comes up.
I would highly appreciate any help or suggestions on how to solve this issue, thanks.
回答1:
This is not the answer, but it will help you.
Start by defining which Google Account you will be saving to. The whole enchilada is totally different if the user will be using his own account, or some centralised account.
Next you need to decide which API/SDK you wish to use. Assuming you want the user to save to his own Google account, you have a choice between using the REST API (with or without the Java SDK) or the Android API. The REST API allows access to all Drive features, but only works when the handset is online and requires a bit of wrangling to get authorised. The Google Drive Android API (GDAA) offers a subest of features, but is easier to get working and has the advantage of allowing offline access.
来源:https://stackoverflow.com/questions/41676982/google-drive-api-cant-connect-authorize-to-google-account