如何与谷歌的小号preadsheet连接Android应用程序小号、应用程序、preadsheet、Android

2023-09-04 06:44:07 作者:疏雨萧萧千行泪

我试图做一个Android应用程序,需要与谷歌小号preadsheet API工作。我在这个新的,所以我开始与API的3版本:https://developers.google.com/google-apps/s$p$padsheets/

I'm trying to do an Android app that needs to work with Google spreadsheet API. I'm new in this, so I'm starting with the version 3 of the api: https://developers.google.com/google-apps/spreadsheets/

我跟所有的步骤,下载的所有jar文件到 LIB 在我的项目文件夹,子文件夹,然后我加入到构建路径在Eclipse中像往常一样。因此,虽然没有Java示例进行的Oauth 2.0,我只是想宣布:

I followed all the steps, downloaded all the jar files to lib subfolder in my project folder and then I added to the build path in Eclipse as usual. So although there is no Java example to perform Oauth 2.0, I just tried to declare:

SpreadsheetService service = new SpreadsheetService("v1");

但是当我仿效这种简单的线条它给了我一个错误:

but when I emulate this simple line it gives me an error:

java.lang.NoClassDefFoundError: com.google.gdata.client.spreadsheet.SpreadsheetService

我用所有包含在文档中的罐子和我有进口:

I'm using all the jars included in the documentation and I have the import:

import com.google.gdata.client.spreadsheet.SpreadsheetService;

但我完全失去了。我不知道自己还能做些什么刚刚启动,连接到谷歌API和带有S preadsheets工作。

but I am totally lost. I dont know what else to do just to start, connect to Google APIs and work with the spreadsheets.

推荐答案

感谢你这么这么多的蝎子!有用!!我一直在想这个时间过长。 确定这里是我的解决方案: 我开始一个新项目,其中包括这些罐子:

Thank you so so much Scorpion! It works!! I've been trying this for too long. Ok here is my solution: I started a new project and included these jars:

gdata-client-1.0
gdata-client-meta-1.0
gdata-core-1.0
gdata-spreadsheet-3.0
gdata-spreadsheet-meta-3.0
guava-13.0.1  

和我的code:

    SpreadsheetService spreadsheet= new SpreadsheetService("v1");
    spreadsheet.setProtocolVersion(SpreadsheetService.Versions.V3);

    try {
        spreadsheet.setUserCredentials("username", "password");
        URL metafeedUrl = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
        SpreadsheetFeed feed = spreadsheet.getFeed(metafeedUrl, SpreadsheetFeed.class);

        List<SpreadsheetEntry> spreadsheets = feed.getEntries();
        for (SpreadsheetEntry service : spreadsheets) {             
            System.out.println(service.getTitle().getPlainText());
       }
    } catch (AuthenticationException e) {           
        e.printStackTrace();
    }

当然,

这是在不同的线程中执行不是在主线程。有没有Java文档的OAuth 2.0,但我会尝试,如果我不能做到这一点,我会问这里。 再次,非常感谢你,我希望能帮助你,当我工作的这段时间就好了。 :)

of course this is executed in a different thread not in the main thread. There is no java documentation for OAuth 2.0 but I will try and if I can't do it I'll ask here. Again, thank you very much and I hope to help you when I work on this time enough. :)

 
精彩推荐