如何导入驱动API客户端库的Java和谷歌API表3.0版 [英] How to import Drive API Client Library for Java and Google Sheets API version 3.0

查看:186
本文介绍了如何导入驱动API客户端库的Java和谷歌API表3.0版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与论坛的资料和大量的挣扎周后,我发现了如何使用这两个驱动器API客户端库用于Java和谷歌API表。我觉得特别为Android文档是很缺乏的,所以我想它做一个文章,解释如何导入API的为Android将是有益的。这就是我希望当我开始使用这两个库我能找到的帖子,我希望这有助于谁可能是碰上了我的问题,有人..

After weeks of struggling with the documentation and plenty of forums I found out how to use both the Drive API Client Library for Java and Google Sheets API. I feel that the documentation especially for android is very lacking so I thought it would be useful to make a post explaining how to import the API's for Android. This is the post I wish I could have found when I started with these two libraries, I hope this helps someone who might have run into my problems..

推荐答案

注:这是Android只,并且定向用于Android的工作室。下面descirbed配置是我在用的,虽然可能有一些不必要的文件,包括它仍然正常工作。的结果所以第一,进口这两个API将给功能获得了用户的谷歌驱动器,并可以编辑该帐户谷歌小号preadsheets。有驱动器API为Android,一两个版本=\"nofollow\">的Andr​​oid ,另一个用于的Java 环境。尽管专为Android做一个很简单的使用,并更好地整合与Android有一个主要的缺点结果注:谷歌云端硬盘Android API目前只支持drive.file和drive.appfolder授权范围。如果您的应用需要额外的权限或驱动器的Andr​​oid API中的功能尚不可用,则必须使用谷歌API的Java客户端。结果这意味着您的应用程序只能访问和编辑文件它自己创造,为此,我选择使用谷歌API的Java客户端。对于谷歌API表有没有真正的替代版本,只是自己。结果现在我曾试图找出哪些文件,我需要进口最困难的时候,对这个文档是hazey所以这里的文件所需。结果把所有这些文件中的应用程序\\库您的应用程序的目录。结果使用驱动器API客户端库的Java 结果第一的下载驱动API第2版客户端库的Java。的readme.html 它描述需要什么样的依赖性为Android。< BR>使用下面的罐子。
结果

Note: this is for Android only, and directed for Android Studio. The configuration descirbed below is what i am using, although there may be some unnecessary files included it does nonetheless work.
So first, the functionality that importing these two APIS will give is access to a users Google Drive, and to edit Google Spreadsheets on that account. There are two "versions" of the Drive API for Android, one made specifically for Android and another for any Java environment. Although the one made specifically for Android is simpler to use and is better integrated with Android it has one major drawback.
Note: The Google Drive Android API currently only supports drive.file and drive.appfolder authorization scopes. If your application requires additional permissions or features not yet available in the Drive Android API, you must use the Google APIs Java Client.
This means your app can only access and edit files it has itself created, for this reason i chose to use the Google APIs Java Client. As for the Google Sheets API there are no real alternative versions, just itself.
Now the hardest time i had was trying to find out which files i needed to import, the documentation on this is hazey so here are the files needed.
Put all these files in the app\libs directory of your app.
To use Drive API Client Library for Java
First "Download the Drive API v2 Client Library for Java." In readme.html it describes what dependencies are needed for android.
Use the following jars.

`google-api-client-android-1.19.1.jar (for SDK >= 2.1)
 google-http-client-android-1.19.0.jar 
 gson-2.1.jar
 protobuf-java-2.4.1.jar`

结果同样包括谷歌API服务驱动-V2-rev161-1.19.1.jar 搜索结果
从的目录下载gdata的库=HTTPS://$c$c.google.com/p/gdata-java-client/downloads/list 相对=nofollow>这里,这包括小号preadhseet罐和其他GDATA库,例如地图,金融,文档,日历等。结果在gdata的\\ java的\\ lib中使用以下文件。结果


Also include google-api-services-drive-v2-rev161-1.19.1.jar

To use Google Sheets API version 3.0
Download gdata library from here, this includes spreadhseet jars and other gdata libraries like maps, finance, docs, calendar, etc..
In the gdata\java\lib use the following files.

`

    gdata-client-meta-1.0.jar
    gdata-core-1.0.jar
    gdata-spreadsheet-3.0.jar
    gdata-spreadsheet-meta-3.0.jar
    google-api-client-1.19.1.jar
    google-api-client-android-1.19.1.jar
    google-api-services-drive-v2-rev158-1.19.1.jar
    google-http-client-1.19.0.jar
    google-http-client-android-1.19.0.jar
    google-http-client-gson-1.19.0.jar
    google-oauth-client-1.19.0.jar
    guava-18.0.jar
    jackson-core-2.1.3.jar
    jackson-core-asl-1.9.11.jar
    jsr305.jar
    protobuf-java-2.4.1.jar
    gdata-base-1.0.jar
    gdata-client-1.0.jar

` 

目录下载的JavaMail ,这是由专为android`


Download javamail, this is made specifically for android`

mail.jar 
activation.jar 
activation.jar`

搜索结果既然你把所有这些在你的应用程序\\ lib目录你的build.gradle应包括以下内容(自己添加这些):`



Now that you have all these in your app\lib directory your build.gradle should include the following(add these in yourself):`

compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/gdata-base-1.0.jar')
compile files('libs/gdata-client-1.0.jar')
compile files('libs/gdata-client-meta-1.0.jar')
compile files('libs/gdata-core-1.0.jar')
compile files('libs/gdata-spreadsheet-3.0.jar')
compile files('libs/gdata-spreadsheet-meta-3.0.jar')
compile files('libs/google-api-client-1.19.1.jar')
compile files('libs/google-api-client-android-1.19.1.jar')
compile files('libs/google-api-services-drive-v2-rev158-1.19.1.jar')
compile files('libs/google-http-client-1.19.0.jar')
compile files('libs/google-http-client-android-1.19.0.jar')
compile files('libs/google-http-client-gson-1.19.0.jar')
compile files('libs/google-oauth-client-1.19.0.jar')
compile files('libs/gson-2.1.jar')
compile files('libs/guava-18.0.jar')
compile files('libs/jackson-core-2.1.3.jar')
compile files('libs/jackson-core-asl-1.9.11.jar')
compile files('libs/jsr305.jar')
compile files('libs/mail.jar')
compile files('libs/protobuf-java-2.4.1.jar')` 

结果最后一步!,因为这些进口罐子有我们需要让我们的应用多dexable方法数量之多的结果,这个过程是很简单的,并描述这里。一旦你做了这所有的设置开始使用驱动器和US preadsheets API,如果你发现这个有用了投票,以便其他可以看到!


Final step!
Because of the sheer number of methods that these imported jars have we need to make our app multi-dexable, this process is very straight forward and is described here.Once you've done this your all set to start using the Drive and Spreadsheets API, if you found this useful up vote so other can see!

这篇关于如何导入驱动API客户端库的Java和谷歌API表3.0版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆