2016-11-17 79 views
3

在網絡上有相當多的類似問題/問題未解決。克隆官方谷歌驅動器安卓演示不起作用

  1. 我只是克隆樣本,採用了android工作室

  2. 根據自述 - >

註冊一個OAuth 2.0客戶端包 com.google.android.gms.drive.sample.demo用自己的調試鍵 並將任何資源ID設置爲您有權訪問的資源ID。資源 ID定義上:
* com.google.android.gms.drive.sample.demo.BaseDemoActivity.EXISTING_FOLDER_ID

  • com.google.android.gms.drive.sample.demo.BaseDemoActivity.EXISTING_FILE_ID
  • 所以OAuth 2.0用戶密鑰進行,文件夾ID的變化和文件ID進行

  • 添加權限

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    
  • 加入意向

    <meta-data android:name="com.google.android.apps.drive.APP_ID" android:value="id=66xxxxxxxxxxx" /> 
        <intent-filter> 
         <action android:name="com.google.android.apps.drive.DRIVE_OPEN" /> 
         <data android:mimeType="application/vnd.google-apps.drive-sdk.66xxxxxxxxxxx" /> 
         <data android:mimeType="image/png" /> 
         <data android:mimeType="image/jpeg" /> 
         <data android:mimeType="image/jpg" /> 
        </intent-filter> 
    
  • 因此,在運行模擬器和真實設備的代碼,

    30570-30570/com.google.android.gms.drive.sample.demo I/BaseDriveActivity: GoogleApiClient connection failed: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{3b3293e8: [email protected]}, message=null} 
    
    30570-30570/com.google.android.gms.drive.sample.demo I/BaseDriveActivity: GoogleApiClient connection failed: ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null, message=null} 
    
    30570-30570/com.google.android.gms.drive.sample.demo E/GoogleApiAvailability: Internal error occurred. Please see logs for detailed information 
    

    真的不知道怎麼回事錯了。

    +0

    看起來你需要添加一個辦法讓你的用戶試圖訪問他們的驅動器之前登錄。 –

    回答

    0

    ConnectionResult指出,這些錯誤可能會在以下情況下會遇到:

    • SIGN_IN_REQUIRED

      客戶端試圖連接到服務,但用戶沒有登錄客戶端可能。選擇繼續而不使用API​​。

    • INTERNAL_ERROR

      發生內部錯誤。重試應該可以解決問題。

    您可能還需要檢查這一步一步的Google Drive Android integration tutorial,看看你是否錯過了一些東西。

    最後,這些GitHub的職位也可能有幫助:

    2

    我只是跳過你的#4,#5步。

    只需啓用Drive Api表單庫即可。

    Google APIs > Library > Drive API