简体   繁体   English

如何在Android上设置Google Drive API?

[英]How to set up Google Drive API on android?

I have been attempting to integrate Google Drive functionality within my application but I am not able to use any of the built-in functions therefore I believe I either missed a step or did it incorrectly. 我一直在尝试将Google云端硬盘功能集成到我的应用程序中,但是我无法使用任何内置功能,因此我相信我错过了一步或执行不正确。 I am following the official Google Developers guide: https://developers.google.com/drive/android/get-started Yet when I use this code, 我正在遵循官方的Google Developers指南: https : //developers.google.com/drive/android/get-started但是,当我使用此代码时,

  mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

it displays as red. 它显示为红色。 I registered a project but what do I do with the result, how is it integrated with my application? 我注册了一个项目,但是如何处理结果,它如何与我的应用程序集成? Can anyone help, guide me through the steps? 谁能帮我指导这些步骤?

You need to go to your app/build.gradle file and add Google Play Services as a dependency: 您需要转到app/build.gradle文件,并将Google Play服务添加为依赖项:

compile 'com.google.android.gms:play-services-drive:9.2.0'

Then resync Gradle and those classes should be available. 然后重新同步Gradle,这些类应该可用。

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

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